A job queue is backed up four hours and half the jobs are now pointless. What do you drain, and what do you drop?
A job queue backlog should be classified into expired jobs, superseded jobs and still-required jobs. Drain the last fully; shed expired work with a record and collapse superseded work by key. Deadlines and collapse keys must be written at enqueue time. It also connects backpressure to the point an interviewer is testing.
Answer
Short answer
For a four-hour job queue backlog, first calculate drain time from backlog size and surplus throughput, then classify jobs by value. Expired jobs should be shed with an audit record, superseded jobs should collapse to the newest desired state, and required jobs such as invoices or webhooks must drain fully. You can only make that decision safely if each job carries a deadline, type and collapse key from enqueue time.
Was this answer helpful?
Likely follow-ups
- Your consumers are at 30 per cent CPU and the backlog is still growing. What is the next thing you measure?
- How would you let a newly-enqueued urgent job overtake fourteen million older ones without starving them for ever?
- What does a collapse key do to ordering guarantees that consumers may already be relying on?
- Six hours after you shed 200,000 jobs, a customer asks what happened to theirs. What can you tell them?
Related questions
- A dependency that normally answers in 80ms starts taking eight seconds. What in your service reacts, and in what order?hardAlso on backpressure7 min
- Traffic is a hundred times normal and some of it is real customers. What do you drop first?hardAlso on backpressure5 min
- Every uploaded image needs six sizes and the thumbnail has to appear immediately. What runs before you return, and what does not?mediumAlso on job-queue5 min
- Your broker stops accepting writes for twenty minutes. What does each producer do, and what should you have decided before it happened?hardAlso on backpressure6 min