Skip to main content

02. Amazon SQS (Simple Queue Service)

Amazon SQS (Simple Queue Service) is a fully managed message queuing service that allows you to decouple and scale microservices, distributed systems, and serverless applications.

When deploying multiple services, direct communication (App → App) can create tight coupling and scaling issues. SQS solves this by acting as a buffer between producers and consumers.


⚙️ How It Works

ComponentRole
Producer (Sender)Sends messages to the SQS queue. Can be one or many producers.
QueueStores messages until they are processed or deleted.
Consumer (Receiver)Polls (requests) messages from the queue and processes them. Can also be one or many consumers.
IAM Roles Example

✅ Multiple producers can send messages.
✅ Multiple consumers can process messages concurrently.
✅ Each message is delivered to only one consumer instance (point-to-point model).


🧱 Architecture Example

Scenario: A video-sharing platform where users upload videos for processing.

LayerDescription
Frontend Web ServersAccept user uploads and send “video processing” messages to SQS.
SQS QueueTemporarily stores video processing requests.
Video Processing EC2 GroupPolls messages from SQS and encodes videos asynchronously.

✅ Web and processing layers are decoupled
✅ Each can scale independently based on workload
✅ Processing layer can auto-scale based on queue length

IAM Roles Example

⚡ Performance & Scaling

  • Scales automatically from 1 to tens of thousands of messages per second.
  • Low latency (< 10 ms for send/receive).
  • No limit on queue size (unlimited messages).
  • Message retention:
    • Default: 4 days
    • Maximum: 14 days
  • Fully managed and serverless — no server provisioning required.

🧠 Exam Tips

FeatureDescription
DecouplingAlways think SQS when you see “decouple application tiers.”
PollingConsumers poll the queue to receive messages.
Visibility TimeoutPrevents other consumers from processing a message that’s already being worked on.
Message DeletionMust be deleted after successful processing.
FIFO QueuesEnsure message order (First-In-First-Out).

🔁 SQS FIFO Queues

FeatureStandard QueueFIFO Queue
OrderNot guaranteedGuaranteed
ThroughputVery highLimited (but consistent)
Use CaseParallel processingOrder-sensitive processing

Example:
If messages are sent as 1 → 2 → 3 → 4,
a FIFO queue ensures consumers receive them in the same order.


🧠 Key Takeaway

Amazon SQS decouples your applications by introducing a message queue between producers and consumers.
It provides scalability, fault tolerance, and asynchronous processing — all fully managed by AWS.

SQS Hands On

Step 1: Create Queue

IAM Roles Example

Step 2: Test Queue

IAM Roles Example