Lesson 1 of 3 Application Integration and Business Applications

Decoupling Applications with Amazon SQS, Amazon SNS and Amazon EventBridge

This lesson explains how application integration services let the parts of an application communicate without being tightly connected, so each part can scale and fail independently. This is called loose coupling.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish Amazon SQS, Amazon SNS and Amazon EventBridge.
  • Explain how a queue protects a service from traffic spikes.

Comparing the services

SQS, SNS and EventBridge all connect the parts of an application loosely, so that one part can fail or slow down without stopping the others. Amazon SQS is a message queue: messages wait safely in the queue until a consumer pulls one, processes it and deletes it, and each message is handled by one consumer. It suits decoupling components and absorbing sudden spikes of work.

Amazon SNS is a publish-subscribe service: a message sent to a topic is pushed at once to every subscriber, which can be email, SMS, mobile push, SQS queues, Lambda functions or HTTP endpoints. It suits alerts and sending one message to many systems. Amazon EventBridge is an event bus: rules examine each event's content and route it to targets such as Lambda or Step Functions. It suits reacting to events from AWS services, your own applications and SaaS partners, and running schedules. The following table summarises the differences.

Amazon SQS
What it isMessage queue
How messages flowPull: consumers fetch messages when ready; messages wait safely in the queue
ReceiversOne consumer handles each message
Use forDecoupling; absorbing traffic spikes
Amazon SNS
What it isPublish/subscribe notifications
How messages flowPush: a message to a topic goes to every subscriber at once
ReceiversEmail, SMS, mobile push, SQS, Lambda, HTTP
Use forAlerts and fan-out to many systems
Amazon EventBridge
What it isServerless event bus
How messages flowRules route events by their content to targets
ReceiversLambda, Step Functions, SQS and more
Use forEvents from AWS services, your apps and SaaS; schedules (EventBridge Scheduler)
Sort into groups

SQS, SNS or EventBridge?

Exam skills 3.8.1

Decide which messaging service each statement describes.

Log in to try this activity Interactive activities are free with an account.

Example

An ordering website places orders in an SQS queue for a separate service to process, so traffic spikes do not overwhelm order processing. AWS Step Functions coordinates multi-step workflows.

The following diagram shows a queue between the website and order processing.

Decoupling with a queue. The ordering website places each order in an Amazon SQS queue instead of calling the order-processing service directly. During a traffic spike, orders wait safely in the queue, and the processing service takes them at its own pace, so it is not overwhelmed and no order is lost if it is briefly unavailable. SNS pushes a message to many subscribers at once, and EventBridge routes events by rules.
Queues absorb spikes and outages.
Worked example

Handling an order without losing it

When a customer places an order, three things must happen: charge the card, notify the warehouse, and email a confirmation. A loosely coupled design uses the integration services:

StepServiceBenefit
The website publishes an "order placed" messageAmazon SNS topicOne message reaches every interested system (fan-out)
Each system has its own queue subscribed to the topicAmazon SQS queuesIf the warehouse system is down, its orders wait safely in the queue
A nightly report runs at 02:00Amazon EventBridge SchedulerNo server needed to run cron jobs

On Black Friday, orders arrive faster than the warehouse system can process them. Instead of failing, the extra orders wait in the SQS queue and are processed as capacity allows. That is the benefit of decoupling: one slow part does not bring down the whole system.

Check yourself

Which service sends one message to many subscribers at once?

Show answer

Amazon SNS, which uses publish and subscribe.

Exam Tips

Remember for the exam

  • To decouple components with a message queue, use SQS.
  • To send notifications to many subscribers by email or SMS, use SNS.
  • Event-driven routing from AWS services or SaaS applications points to EventBridge.
  • SQS pulls and stores messages; SNS pushes them to many subscribers.
  • To coordinate multi-step workflows, use Step Functions.