ORIGINAL TECHNICAL PRACTICE
Handle an expanding work queue
A background processing queue grows faster than workers can drain it. What would you examine and change?
Written for independent practice. The model answer presents one approach; clarify constraints and explain alternatives.
A REASONED APPROACH
Model answer.
Compare arrival rate, processing capacity and acceptable queue delay. Backpressure should protect downstream systems and give callers a clear outcome when the service cannot meet its contract.
Work through it
- Measure queue age as well as length, processing-time distribution, retry volume and failures by job type. Determine whether the bottleneck is compute, a dependency or a serial resource.
- Increase useful capacity only where the constrained dependency can support it. Limit concurrent work, isolate expensive jobs and apply admission control or quotas for overload.
- Define retry, dead-letter, expiry and cancellation behavior. Validate how duplicate delivery and worker crashes affect results before relying on more consumers.
Tradeoffs to discuss
- A queue smooths bursts but cannot absorb an indefinite capacity deficit. More workers may increase contention or overload a downstream service.
Common pitfalls
- A small queue can still contain a very old blocked job. Unlimited retries and large unbounded payloads can consume capacity without producing useful completed work.