โ˜๏ธAWSDVA Prep
← All cheat sheets
๐Ÿ“ฌ

SQS & SNS

Development with AWS Services

Decoupled, asynchronous messaging โ€” queues (SQS) and pub/sub (SNS).

SQS basics

  • โ–ธStandard queue: at-least-once delivery, best-effort ordering, near-unlimited throughput.
  • โ–ธFIFO queue: exactly-once processing, strict ordering, name must end in .fifo.
  • โ–ธVisibility timeout: time a message is hidden after being received, before becoming visible again (default 30s).
  • โ–ธLong polling (up to 20s) reduces empty responses and cost vs short polling.

SQS reliability

  • โ–ธDead-letter queue (DLQ): captures messages that fail maxReceiveCount times via a redrive policy.
  • โ–ธMessage retention: 1 minute to 14 days (default 4 days).

SNS basics

  • โ–ธPub/sub push-based messaging โ€” no polling, no persistent storage of messages.
  • โ–ธFan-out pattern: one SNS topic โ†’ many SQS queues/Lambda functions/HTTP endpoints/email/SMS.
  • โ–ธMessage filtering: subscribers can set a filter policy to receive only a subset of published messages.

Comparisons

  • โ–ธUse SQS to decouple producer/consumer with buffering and retry semantics.
  • โ–ธUse SNS when multiple independent systems need the same event simultaneously.
  • โ–ธEventBridge extends this pattern with schema registries, third-party SaaS sources, and content-based routing rules.
Test yourself on this โ†’