Skip to the page

Running apps on AWS · mid

SQS, SNS and EventBridge

SQS is a queue that workers pull from (a message is hidden for a visibility timeout while one worker handles it, and goes to a dead-letter queue after too many failed attempts), SNS pushes one message to many subscribers, and EventBridge routes events by rules and runs schedules.

The notes

What you must know

  • SQS standard queues: at-least-once delivery, best-effort ordering, nearly unlimited throughput. FIFO queues: ordered per message group, with deduplication.
  • Visibility timeout: a received message is hidden; if the worker does not delete it before the timeout (crash, slow), it becomes visible again and is retried. Set the timeout longer than the processing time.
  • Dead-letter queue: after maxReceiveCount failed receives the message moves to a DLQ for inspection and redrive.
  • Consumers must be idempotent (duplicates happen). Lambda can consume SQS in batches; report partial batch failures so only failed messages retry.
  • SNS: pub/sub fan-out (one 'OrderPlaced' message to several SQS queues, Lambda, email or SMS). SNS -> SQS fan-out gives each consumer its own queue and retries.
  • EventBridge: an event bus with content-based routing rules, partner integrations, and EventBridge Scheduler for cron-like jobs.

The red pen

Common traps: mistake → fix

  • Mistake: SQS delivers each message exactly once

    Fix: standard queues are at-least-once; design idempotent consumers.

  • Mistake: Receiving a message removes it

    Fix: it is only hidden; you must delete it after processing.

Easy to hard

Questions interviewers ask, easy to hard

  1. SQS vs SNS vs EventBridge?
  2. What is a visibility timeout? What happens if the worker crashes?
  3. What is a dead-letter queue?
  4. How do you send one 'order placed' event to email, analytics and warehouse services?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview