Tech Interview RoomStudy guides

AWS

When do you use SQS, SNS, EventBridge, Kinesis or MSK?

Intermediate · 2 min read · Lesson 2 of 7 in AWS

  • SQS: a durable queue for point-to-point work distribution. Consumers poll; each message is processed by one consumer; scales automatically.
    • Standard: nearly unlimited throughput, at-least-once delivery, best-effort ordering.
    • FIFO: exactly-once processing within a deduplication window and strict ordering per MessageGroupId, with lower throughput (high-throughput mode helps).
    • Visibility timeout hides a received message while it is processed; if not deleted in time it reappears. Dead-letter queue after maxReceiveCount failures.
  • SNS: pub/sub fan-out with push delivery to SQS queues, Lambda, HTTP endpoints, email and SMS. The classic pattern is SNS → multiple SQS queues so each consumer service has its own durable buffer.
  • EventBridge: an event bus with content-based routing rules, schema registry, archive and replay, SaaS integrations and scheduled events. Ideal for decoupled event-driven integration across many services and accounts at moderate throughput.
  • Kinesis Data Streams: an ordered, replayable stream with shards (like Kafka partitions); multiple consumers read the same data; retention up to 365 days. For real-time analytics, clickstreams and log ingestion.
  • MSK: managed Apache Kafka, when you want the Kafka API and ecosystem (Kafka Streams, Connect, Debezium) or are migrating existing Kafka workloads.

Follow-up questions interviewers ask

Try answering each one before you open it.

How do you choose the SQS visibility timeout?

Set it longer than the maximum processing time (AWS suggests about 6× the Lambda function timeout when Lambda is the consumer), so a message is not redelivered to a second consumer while the first is still working. For long or variable work, extend the timeout from the consumer with ChangeMessageVisibility as a heartbeat. Too long delays retries after a crash.

How do you get ordering and exactly-once with SQS?

Use a FIFO queue with a MessageGroupId per entity (order id): messages within a group are delivered in order and one at a time, and MessageDeduplicationId (or content-based deduplication) drops duplicates sent within 5 minutes. Consumers should still be idempotent, because "exactly once" covers delivery into the queue and processing within the visibility rules, not side effects after a crash.