Why queues exist
Synchronous calls are brittle: the caller blocks until the callee responds. If the payment service takes 3 seconds, your checkout API takes 3 seconds. If the payment service is down, checkout is down. Scale them independently? You can't — they're coupled at the protocol level.
A message queue breaks that coupling. The producer writes a message and returns immediately. The consumer reads it whenever it's ready. Suddenly:
- Latency: checkout responds in 20 ms, not 3 s.
- Resilience: payment service restarts? Messages wait in the queue, not dropped.
- Scale independently: add payment workers without touching checkout.
- Traffic shaping: a queue absorbs a 10x spike; consumers work at their own pace.
Real numbers: AWS SQS processes over 1 million messages/second at peak. A single Kafka partition sustains ~100 MB/s throughput. For an e-commerce platform handling 50k orders/hour (~14 orders/sec), a queue makes the payment worker fleet the scale knob, not the checkout API.
