Scalable, Reliable and Fault-tolerant inter-microservice communication via AWS SNS

Asanka Nissanka
codeburst
Published in
4 min readApr 13, 2020

--

Photo by Alina Grubnyak on Unsplash

Mico-services has become a popular term within the IT industry today, and as I see it’s a good approach to build systems, however there are both ups and downs if you choose that approach and it’s your responsibility to select the best approach for your context.

I am going to discuss a practical challenge (I prefer to say like that since it’s a mess if we don’t tackle it in the correct way) that we face when working with the so called microservices, and going to explain a production ready solution I have used.

Inter-microservices communication is an obvious challenge we face after decomposing our applications into services. In most cases certain tasks are handled by several services. Some are required to complete the tasks and some are are required to run after completion of another task like analytics. In either case, we need to comminicate between services in an effective way which is scalable and fault tolerant. There are types of communications as,

  • Synchronous communication
  • Asyncrhonous communication

Synchronous communication is obvious since we are waiting for a response from the other service and we know what has happend depending on that. However for asynchronous communication we are not waiting for a response immediately from the other service and often the caller service doesn’t need to know what happend. However it is crucial that the message reach the other service. So it is advisable to use a message mediation mechanism in case of asynchronous communication between services.

I am going to explain a solution architecture using AWS Simple Notification Service (SNS) to communicate between both serverless and non-serverless (couldn’t think of a better word than this 🤔) services.

AWS SNS is a highly available, durable, secure and fully managed pub/sub messaging service. We can publish messages from anywhere via the SNS API (SDKs also available for popular languages) and consume messages via different methods. SNS natively support several protocols for subscribers and listed below is a subset of them for the interest of this arcticle.

  • HTTP/S
  • Amazon SQS

--

--