Lesson 14 of 30
The question that actually separates these two services isn't which is 'better' — it's whether exactly one thing should handle a message, or every interested thing should.
12 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A consumer reads a message from a Standard SQS queue, starts processing, then crashes before deleting it. What happens to that message?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
SQS (Simple Queue Service) is a queue: a producer drops a message in, and exactly one consumer picks it up, processes it, and deletes it. SNS (Simple Notification Service) is publish/subscribe: a producer publishes one message to a topic, and every subscriber attached to that topic gets its own copy. That's the whole distinction — one consumer per message versus many.
The reason either exists at all is decoupling. Without a queue, a producer calling a slow or occasionally-down consumer directly means the producer's request hangs or fails along with it. Drop a message in SQS instead, and the producer's job is done the instant the message is accepted — the consumer reads at its own pace, and a consumer that's temporarily overwhelmed or offline just means messages wait in the queue instead of the producer failing.
An OrderPlaced event needs to trigger billing, shipping, and analytics — three independent systems that each need to know, but shouldn't block each other or the checkout flow.
OrderPlaced --publish--> SNS topic "orders"
|-- subscribe --> SQS: billing-queue
|-- subscribe --> SQS: shipping-queue
+-- subscribe --> SQS: analytics-queue
Checkout publishes OrderPlaced once, to the SNS topic "orders" — it knows nothing about billing, shipping, or analytics.
The checkout service publishes once, to the topic, and knows nothing about billing, shipping, or analytics individually. SNS delivers a copy of that message into each subscribed SQS queue, and each queue is then consumed independently — the shipping worker being slow or temporarily down has zero effect on billing processing, because they're reading from entirely separate queues. This fan-out pattern (SNS topic fanning out to multiple SQS queues) is the standard way to get "one event, several independent reactions" without hardcoding those reactions into the publisher or making them block each other.
"When would you reach for SQS versus SNS?" is a common systems-design question, and the sharp answer isn't a memorized rule — it's recognizing that the real question is "should exactly one thing handle this, or should every interested thing hear about it," with fan-out (SNS publishing into several SQS queues) as the pattern that gets both at once.