简体   繁体   English

AWS SNS与AWS步骤功能

[英]AWS SNS vs AWS Step Functions

What's the better option to coordinate tasks between microservices? 在微服务之间协调任务的更好选择是什么?

For example, if I have a microservice that handles customer information and need to notifies other microservices, is it better to create a workflow (AWS Steps) between microservices or use a SNS? 例如,如果我有一个处理客户信息并需要通知其他微服务的微服务,那么在微服务之间创建工作流(AWS Steps)或使用SNS是否更好?

I think AWS Steps will couple my lambda functions, and SNS not. 我认为AWS Steps将耦合我的lambda函数,而SNS不会。

AWS Step Functions is a step machine that executes AWS Lambda functions. AWS Step Functions是执行AWS Lambda函数的步骤机器。 If your task involves "do this, then this" activities, then Step Functions could be a good option. 如果您的任务涉及“执行此操作,那么这个”活动,那么步骤功能可能是一个不错的选择。 It includes logic to determine the next step and automatically handles retries. 它包括确定下一步并自动处理重试的逻辑。 It's the modern version of Amazon Simple Workflow (SWF) . 它是Amazon Simple Workflow(SWF)的现代版本。

Amazon Simple Notification Service (SNS) can also trigger Lambda functions, but it does not handle the logic nor the retries. Amazon Simple Notification Service(SNS)也可以触发Lambda函数,但它不处理逻辑和重试。 It's a good fit for decoupled services, especially for fan-out where multiple subscribers receive the same message from a topic -- for example, for triggering multiple Lambda functions or sending multiple notifications. 它非常适合解耦服务,尤其适用于多个订阅者从主题接收相同消息的扇出 - 例如,用于触发多个Lambda函数或发送多个通知。 It's basically a public/subscribe service, of which Lambda is one of the subscriber types. 它基本上是一个公共/订阅服务,Lambda是其中一种订阅者类型。

The choice will depend upon your particular use-case. 选择取决于您的特定用例。 If you don't want to redesign things to use Step Functions, then send notifications via SNS. 如果您不想重新设计使用步骤功能的东西,请通过SNS发送通知。 If you sometimes send notifications (eg emails) rather than just trigger Lambda functions, use SNS. 如果您有时发送通知(例如电子邮件)而不是仅触发Lambda函数,请使用SNS。

Currently, Step Functions is not available in every region, while SNS is everywhere so that might also influence your choice. 目前,步骤功能并非在每个地区都可用,而SNS无处不在,因此可能也会影响您的选择。

It depends on what type of coordination you want. 这取决于您想要的协调类型。 Synchronous or Asynchronous. 同步或异步。

If it is synchronous and if you really want some co-ordination between them, then Amazon Simple Notification Service (SNS) would not help and AWS Step Functions would be the way to go. 如果它是同步的,并且如果你真的想在它们之间进行一些协调,那么亚马逊简单通知服务(SNS)将无济于事,并且AWS步骤功能将成为可能。

But if the requirement is asynchronous, and you just want to notify/invoke the microservices then SNS would be a better fit. 但是如果需求是异步的,并且您只想通知/调用微服务,那么SNS将更适合。

As I can read from your question "need to notify other microservices" I assume it is just about notifying them (as against to co-ordinating them) and each would know what to do further without relying on other microservices. 正如我可以从你的问题中读到“需要通知其他微服务”我认为它只是通知它们(而不是协调它们),并且每个人都知道如何进一步做,而不依赖于其他微服务。 And if that is true then SNS is a good fit. 如果这是真的那么SNS是一个不错的选择。

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

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