简体   繁体   English

我可以通过启动轮询队列的多个 EC2 实例来并行处理多个 SQS 消息吗?

[英]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.

相关问题 如何使用多个 eip 和 ec2 实例创建 terraform aws_security_group? - How can I create terraform aws_security_group with multiple eip and ec2 instances? Terraform 在多个 su.net 中创建多个 ec2 实例 - Terraform create multiple ec2 instances in multiple subnets aws ec2 上的 Gitlab runner:让一个 ec2 启动多个并发作业 - Gitlab runner on aws ec2 : Have one ec2 launching multiple concurrent jobs 限制用户启动 EC2 实例 - restricting users from launching EC2 instances 如果我想在多个 Windows EC2 实例之间共享一个卷,我应该使用什么服务? - What service should I use if I want to share a volume across multiple Windows EC2 instances? 两个 AWS SQS FIFO 队列消费者何时可以处理具有相同组消息 ID 的消息? - When can two AWS SQS FIFO queue consumers process messages with the same group message id? 如何列出多个账户(配置文件)的所有 EC2 实例 - How to list all EC2 instances of multiple accounts (profiles) 多个 EC2 实例匹配; 使用额外的约束来减少对单个 EC2 实例的匹配 - multiple EC2 Instances matched; use additional constraints to reduce matches to a single EC2 Instance 在另一个实例中启动 EC2 AMI 后,哪些设置会导致网站无法运行? - Which settings can make a website not working after launching an EC2 AMI in another instance? 如何在 2 个 ec2 实例上连接 2 个不同的 docker 容器? - How can I connect 2 different docker containers on 2 ec2 instances?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM