Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

I think AWS Steps will couple my lambda functions, and SNS not.

like image 727
p.magalhaes Avatar asked Apr 11 '17 02:04

p.magalhaes


Video Answer


2 Answers

AWS Step Functions is a step machine that executes AWS Lambda functions. 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 Notification Service (SNS) can also trigger Lambda functions, but it does not handle the logic nor the retries. 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. It's basically a public/subscribe service, of which Lambda is one of the subscriber types.

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. If you sometimes send notifications (eg emails) rather than just trigger Lambda functions, use SNS.

Currently, Step Functions is not available in every region, while SNS is everywhere so that might also influence your choice.

like image 197
John Rotenstein Avatar answered Sep 21 '22 21:09

John Rotenstein


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.

But if the requirement is asynchronous, and you just want to notify/invoke the microservices then SNS would be a better fit.

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.

like image 34
Arafat Nalkhande Avatar answered Sep 23 '22 21:09

Arafat Nalkhande