简体   繁体   English

缓存AmazonSQS对象好吗

[英]Is it good to cache AmazonSQS object

I am using the below jar for SQS 我正在使用以下罐子进行SQS

  • aws-java-sdk-core-1.11.397.jar aws-java-sdk-core-1.11.397.jar
  • aws-java-sdk-sqs-1.11.397.jar aws-java-sdk-sqs-1.11.397.jar

In my scenario i will be using the same SQS multiple times and getting AmazonSQS object using AmazonSQSClientBuilder. 在我的场景中,我将多次使用相同的SQS,并使用AmazonSQSClientBuilder获取AmazonSQS对象。 I am wondering if we can cache this to help improving performance. 我想知道我们是否可以缓存它以帮助提高性能。

Would caching really help , which will be the best approach to do it and for how long can the object be cached. 缓存确实有帮助,这将是最好的方法,并且可以将对象缓存多长时间。

Current scenario 当前情况

Will be getting message to post SQS on a particular event whose frequency might vary from no event to around 10000 per hour. 将收到消息以在特定事件上发布SQS,该事件的频率可能从无事件变化到每小时大约10000。 This is the reason why i am think to cache it. 这就是为什么我认为要缓存它的原因。

You should most definitely reuse the AmazonSQS instance that is returned from the AmazonSQSClientBuilder. 您绝对应该重用从AmazonSQSClientBuilder返回的AmazonSQS实例。 If you're posting thousands of messages, you shouldn't need to make any other calls to SQS other than sendMessage . 如果要发布数千条消息,则除了sendMessage之外,不需要对SQS进行任何其他调用。

You could also call sendMessageBatch if you have a lot of messages to send. 如果要发送大量消息,也可以调用sendMessageBatch However, SQS is extremely scalable, and 10,000 messages per hour will not even make it sweat so I don't think you'll have anything to worry about. 但是,SQS具有极高的可伸缩性,每小时10,000条消息甚至不会使您汗流so背,因此我认为您不必担心任何事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM