与将SNS到SQS到SQSconsumers相比,将SNS到SQS到Lambda有什么好处?
我们有一个SQS队列订阅SNS主题,该主题每月发布约1-500万个事件。我想知道这些组合中的哪种 - sns-> sqs-> lambda vs sns-> sqs-> sqsconsumer将使我受益于我。
我了解它们之间的维持差异是事件驱动与拉力驱动。触发了进入队列的每条消息的lambda,因此这是事件驱动的体系结构,SQSconsumer必须不断对消息进行轮询。您必须有像这样的民意调查器与lambda这样的持续时间,该lambda仅在收到消息后才触发。
我在这里有几个问题:
- 为什么要sns-> sqs-> Lambda被认为是事件驱动的,当Lambda必须对SQS队列进行轮询类似于SQSconsumer的行为?
- 后续:当Lambda也不断进行轮询时,为什么Lambda被认为比SQSconsumer更具成本效益?
We have a SQS queue subscribe to SNS Topic which publishes about 1-5 million events per month. I want to know which of these combinations - SNS->SQS->Lambda vs SNS->SQS->SQSConsumer would benefit me for such use-cases.
I understand the maintain difference between them is Event driven Vs Pull Driven. A lambda is triggered for each message that comes into a queue so that is an event driven architecture, an SQSConsumer has to constantly poll for messages. You have to have constant up time for a poller like that vs a lambda that is only triggered once a message is received.
I have couple of questions here :
- Why SNS->SQS-> Lambda is considered Event driven, when lambda has to poll the SQS queue similar to what SQSConsumer does?
- Followup : When Lambda is also constantly polling, then why lambda is considered to be more cost efficient than SQSConsumer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您忽略了如何实现使用AWS Lambda的Amazon SQ的“内部”,则只需将其视为直接触发lambda函数的SQS即可。这是一个无服务器模型,而使用SQS消费者需要代码在某个地方的计算机上运行。 Lambda将自动扩展,因此,它比让计算基础架构等待事件(即使不使用)更具成本效益。
因此,这确实是关于是否使用无服务器体系结构的决定。
您也可以在中间使用Amazon SQS订阅AWS lambda功能方向到Amazon SNS主题。
If you ignore the 'internals' of how Amazon SQS with AWS Lambda is implemented, simply think of it as SQS directly triggering the Lambda function. This is a serverless model, whereas using an SQS consumer requires code to be running on a computer somewhere. Lambda will automatically scale, so it is more cost effective than having computing infrastructure waiting around for events (and costing money even when it isn't used).
So, it's really a decision about whether to use a serverless architecture.
You could also subscribe the AWS Lambda function direction to the Amazon SNS topic, without using Amazon SQS in the middle.