Full answer
The problem
A producer sends 10,000 messages per second; the consumer handles 8,000. Every second, 2,000 more wait. With an unbounded queue, memory grows until the process crashes, and every message waits longer and longer, so by the time work is done it may be useless (the user has given up).
Ways to apply backpressure
- Bounded queues. Give each queue a maximum size. When it is full, the producer blocks (waits), gets an error, or the oldest or lowest-priority item is dropped. Blocking pushes the slowdown upstream, which is exactly the point.
- Pull instead of push. Consumers request a batch when ready (Kafka consumers poll; Reactive Streams
request(n)). They can never be given more than they asked for. - Flow control in protocols. TCP's receive window tells the sender how much more data the receiver can buffer; HTTP/2 and gRPC have stream-level windows.
- Explicit rejection. Services return 429 (too many requests) or 503 with
Retry-After. Well-behaved clients back off with exponential delays and jitter. - Concurrency limits. Allow only N requests in progress per service; adaptive limiters lower N when latency rises.
Load shedding
If the source cannot slow down (users clicking, sensors sending), drop work on purpose:
- Reject new requests early, before spending resources on them.
- Prefer important traffic (checkout over recommendations).
- Drop requests that have already waited longer than their deadline.
Example
A video platform sends upload events to a transcoding queue. During a viral event, uploads double. The queue is bounded; when it reaches its limit, the upload API keeps accepting files (cheap) but marks transcoding as "queued", workers autoscale, and low-priority tasks such as thumbnail regeneration pause. Nothing crashes and important work continues.
Signs you need it
Growing queue lengths, rising memory, timeouts cascading from one service to its callers, and retries making overload worse. Monitor queue depth and age, not only throughput.
By level
Fresher: Explain that when a receiver is too slow, the sender must be told to slow down or work will pile up. A fresher should describe a queue with a size limit.
Mid: Describe bounded queues, pull consumers, flow control, 429 responses with backoff and concurrency limits. Explain when to shed load.
Senior: Discuss adaptive limits, deadline-based dropping, priority classes, retry storms and queue age monitoring. Expect end-to-end thinking across services.
Key points
- Backpressure tells fast producers to slow down
- Bounded queues block, reject or drop when full
- Pull-based consumption and protocol flow control limit what is sent
- 429 or 503 with Retry-After plus client backoff
- Load shedding drops low-priority or expired work when slowing is impossible
Common mistakes
- Using unbounded queues and hoping consumers catch up
- Retrying immediately on overload errors
- Doing expensive work before deciding to reject
- Monitoring throughput but not queue age
Follow-ups
- How does TCP flow control work?
- How would you choose a queue size?
- What is an adaptive concurrency limit?
Tips
- Give the 10,000 versus 8,000 example
- List three concrete mechanisms
- Explain load shedding as the last resort
Evaluation rubric
- Correct definition
- Several mechanisms explained
- Load shedding and prioritisation
- Monitoring signals