简体   繁体   中英

Can I process multiple SQS messages in parallel by launching multiple EC2 instances which poll the queue?

I have an SQS queue which contains messages that need not be consumed in order. This queue is mostly for decoupling purpose. I have 2 EC2 hosts that I would want to poll this queue. The processing of each message takes time. While one of my EC2 instance is processing a message, can my other EC2 poll the next message from the queue?

If this cannot be done, then is using an SQS an incorrect approach here? Should I instead configure an autoscaling group of EC2 instances and load balance the incoming requests among the EC2 instances?

Yes it is possible, when a instance grabs the message it is put in " Messages in flight" status. this is not available to other instances polling the queue.

Efectly reserving that message for that consumer.

more info here https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/features-capabilities.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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