[英]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.我有一个 SQS 队列,其中包含不需要按顺序使用的消息。 This queue is mostly for decoupling purpose.
该队列主要用于解耦目的。 I have 2 EC2 hosts that I would want to poll this queue.
我有 2 个 EC2 主机,我想轮询这个队列。 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?
当我的一个 EC2 实例正在处理一条消息时,我的另一个 EC2 实例是否可以轮询队列中的下一条消息?
If this cannot be done, then is using an SQS an incorrect approach here?如果无法做到这一点,那么在这里使用 SQS 是一种不正确的方法吗? Should I instead configure an autoscaling group of EC2 instances and load balance the incoming requests among the EC2 instances?
我是否应该配置一个自动缩放的 EC2 实例组并在 EC2 实例之间对传入请求进行负载平衡?
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更多信息在这里https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/features-capabilities.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.