Work Queue
Also known as: task queue, job queue.
A queue that holds jobs until workers can claim and process them, separating the rate at which work is submitted from the rate at which it is completed.
Synthetic dataExamples on this page use synthetic data created for illustration.
Definition
A work queue holds jobs until one or more workers can claim and process them. It separates submission from execution, absorbs short bursts of work, and lets workers operate at their own pace. Acknowledgements and redelivery rules determine what happens when a worker fails before finishing.
In plain terms
Imagine a tray of tasks between the person requesting work and the people doing it. Requesters can add cards without waiting for a worker to be free. Each free worker takes a card, does the work and marks it complete. If work arrives faster than it is completed, the tray grows.
That separation is useful, but a queue is not automatically reliable. The system still needs to decide when a job counts as claimed, how long that claim lasts, when to offer the job again and how to avoid an unsafe retry. A Lease is one common way to put a time limit on a claim.
Example
A service receives 12 image-resizing jobs in one minute. Three workers each complete two jobs per minute.
| Time | Jobs submitted | Jobs completed | Jobs waiting |
|---|---|---|---|
| Start | 12 | 0 | 12 |
| After 1 minute | 0 | 6 | 6 |
| After 2 minutes | 0 | 6 | 0 |
The queue absorbs the one-minute burst, and the workers empty it over two minutes. If one worker stops after claiming a job, the queue needs an acknowledgement or lease rule to decide whether and when that job should be offered again.
Common misunderstandings
- “A queue guarantees first-in, first-out completion.” It may preserve claim order, but jobs can take different amounts of time, fail or be retried, so completion order can differ.
- “Taking a job removes it forever.” Reliable queues usually wait for an acknowledgement or a lease outcome before treating the job as complete.
- “More workers always make work finish faster.” Shared databases, external services and exclusive resources can become the limit; extra workers can then add contention rather than capacity.
References
- RabbitMQ tutorial - Work Queues . RabbitMQ.
- Martin Kleppmann. Designing Data-Intensive Applications . O'Reilly Media, 2017. ISBN 978-1449373320.