๐ฌ
SQS & SNS
Development with AWS ServicesDecoupled, 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.