← InterviewIntermediate
What Happens When the Producer Is Faster Than the Consumer?
A producer generates work faster than a consumer can handle it. What are your options, and what does each cost?
The scenario
An ingestion service reads from a socket and pushes onto an in-memory list consumed by four workers. Under a burst the process RSS climbs from 400MB to 6GB over twenty minutes and is OOM-killed. The list has no maximum.
What it tests
- Whether the candidate sees an unbounded queue as a deferral rather than a solution
- Whether they can enumerate the real options and attach a cost to each
- Whether they know backpressure has to propagate to the source to work
Answer it out loud first. Recognising a good answer is not the same skill as producing one.