AWS SQS, SNS, and EventBridge: A Comparative Study

W Rashmika Lakshan
4 min readJan 15, 2024

--

Amazon Web Services (AWS) offers a variety of message orchestration services, each with its unique features and advantages. Three such services are Simple Queue Service (SQS), Simple Notification Service (SNS), and EventBridge. Although they have somewhat similar names, they provide very different functionalities. Let’s delve into each of these services to understand their differences and use cases.

AWS Simple Queue Service (SQS)

SQS is one of the oldest services developed and launched by AWS. It facilitates the decoupling of applications and enables asynchronous communication between services. Developers can publish messages to a queue, which the consuming application can process either immediately or at a later time.

  • Queues: These are the destinations where messages are published.
  • Messages: These are the content or payload that gets sent to the queue.
  • Producers: These are the applications that send messages to SQS queues.
  • Consumers: These are the applications that read and process messages from SQS queues.
  • Visibility Timeout: This is the period during which a message is invisible to other consumers after it has been read and processed by a consumer.
  • Long Polling: This technique is used to reduce the cost associated with polling SQS queues by requesting messages only when new messages arrive in the queue.

AWS Simple Notification Service (SNS)

SNS is a fully managed pub/sub messaging service that allows you to fan out push messages from publishers to subscribers. It provides topics for high-throughput, push-based, many-to-many messaging. Using SNS topics, your publisher systems can distribute messages to a large number of subscriber systems including Amazon SQS queues, AWS Lambda functions, and HTTP/S webhooks for parallel processing, and you can even fan out delivery to push endpoints such as mobile devices for direct message delivery.

  • Topics: These are the logical access points and communication channels. Publishers communicate asynchronously with subscribers by sending messages to a topic.
  • Messages: These are the data or payload that gets sent to the topic.
  • Publishers: These are the applications or users that send messages to SNS topics.
  • Subscribers: These are the applications or users that read and process messages from SNS topics.
  • Supported Services: Amazon SNS supports multiple protocols including Amazon SQS, HTTP/S, email, SMS, and AWS Lambda.
  • Message Delivery: Amazon SNS provides message delivery from publishers to subscribers (also known as producers and consumers). Clients can subscribe to the SNS topic and receive published messages using a supported endpoint type.

AWS EventBridge

EventBridge is a serverless event bus service that makes it easy to connect applications using data from your applications, Software-as-a-Service(SaaS) applications, and AWS services. EventBridge delivers a stream of real-time data from event sources and routes that data to targets like AWS Lambda. You can set up routing rules to determine where to send your data to build application architectures that react in real-time to all of your data sources.

  • Event Buses: These are routers that receive events and deliver them to zero or more destinations, or targets. They are used to route events from many sources to many targets, with optional transformation of events before delivery to a target.
  • Events: In the context of event-driven architecture (EDA), an EventBridge event is a JSON object sent to an event bus or pipe. An event often represents an indicator of a change in a resource or environment.
  • Event Sources: EventBridge can receive events from event sources including AWS services, custom applications, and Software as a Service (SaaS) partners.
  • Rules: A rule receives incoming events and sends them as appropriate to targets for processing. You can specify how each rule invokes its targets based on either an event pattern, which contains one or more filters to match events, or a schedule to invoke the targets at regular intervals.
  • EventBridge Scheduler: This is a serverless scheduler that allows you to create, run, and manage tasks from one central, managed service.

When To Use What?

  • SQS is best suited for asynchronous messaging and decoupling systems.
  • SNS is best suited for real-time messaging and notifications.
  • EventBridge is best suited for real-time event-driven architectures and connecting different services.

In conclusion, SQS, SNS, and EventBridge are powerful tools provided by AWS. The choice between them depends on your specific use case and requirements. Understanding their differences can help you make an informed decision about which service to use in your application architecture.

References

--

--

No responses yet