Skip to main content

Mastering Decoupled Cloud Architecture with Messaging and Queueing | Amazon SNS and SQS

In this blog, we'll explore microservices architecture—a modern approach to software development that brings flexibility, scalability, and resilience. We'll explain what microservices are and how they differ from traditional architectures, emphasizing the benefits they offer for application development. Additionally, we'll uncover the important role of messaging and queueing services like Amazon SNS and SQS in creating responsive and modular applications. 

monolithic vs microservices illustrated

Monolithic applications are the traditional architecture for applications, which were the standard until the introduction of the Microservices approach. However, they are still in use today, particularly for simple landing pages or business websites. For more complex applications, the Microservices approach is religiously followed. The table below compares the monolithic and microservices approaches, highlighting their respective advantages and disadvantages:

Monolithic Approach Microservices Approach  
All components tightly integrated as a single unit Individual components (services) with independent deployments Architecture
Scaling requires scaling the entire application Individual services can be scaled independently Scalability
Lack of modularity and code reusability Promotes modularity and code reusability Modularity
Development cycles tend to be slower and less agile Faster development cycles and easier adoption of new technologies Development
A failure in one component can impact the entire application Failures are isolated to specific services, limiting impact Fault Isolation
Limited flexibility to use different technologies for different parts Flexibility to use diverse technologies for each service Technology Stack
Requires deploying the entire application as a single unit Individual services can be independently deployed Deployment
Complex maintenance and upgrades due to tight coupling Easier maintenance and upgrades with independent services Maintainability
Components communicate through in-memory method calls or APIs Services communicate via lightweight protocols like HTTP or AMQP Communication

Messaging and queueing

One way to decouple an application is to use messaging and queueing services like Amazon Simple Notification Service (SNS) and Amazon Simple Query Service (SQS). 

Amazon Notification Service (SNS)


Amazon SNS

  • Amazon Simple Notification Service (Amazon SNS) is a publish/subscribe service.
  • Using Amazon SNS topics, a publisher publishes messages to multiple subscribers simultaneously. Subscribers could be web servers, email addresses, AWS Lambda functions, etc.
  • SNS supports Application-to-application (A2A) and Application-to-person (A2P) communication.
  • SNS doesn't persist the messages - it delivers and deletes them. SNS is used for applications with simple notification features. 
  • In SNS, message ordering is not guaranteed.

Amazon Queue Service (SNS)

Amazon SQS
  • Using Amazon SQS, you can send, store, and receive messages between software components, without losing messages or requiring other services to be available. 
  • In Amazon SQS, an application sends messages into a queue. A user or service retrieves a message from the queue, processes it, and then deletes it from the queue. SQS follows a one-to-one messaging pattern.
  • SQS only supports Application-to-application (A2A) communication.
  • In SQS, messages are processed in the order they are received.
  • SQS is used in asynchronous, reliable, and ordered message processing. SQS allows microservices to operate independently by posting messages to queues. For example, in an e-commerce application, when a customer places an order, the Order service publishes the order details to an SQS queue. The Email and Inventory services, subscribed to the queue, retrieve the order message and process it asynchronously. This decoupling improves scalability, performance, and fault tolerance, as each service can operate at its own pace and independently scale.


Comments

Popular posts

Discrete Mathematics - Inference Rules for Propositional Logic

Cloud Computing Introduction | Definition, Benefits and Deployment Strategies

What is Amazon EC2? Definition, Types and Pricing