Lesson 5 of 6

Queue photo previews

The cache helps readers get guide pages. Guide authors have a different problem. When they upload a photo, the site must save the original, then resize a preview. Trail Notes records the original and queues the slower resize so authors can get an acknowledgment while a worker builds the preview.

Predict. A burst adds 100 preview jobs per second for 10 seconds. Workers complete 20 per second throughout the burst, starting with an empty queue. How many jobs are pending at the end? How long will they take to drain if no more arrive?

Reveal the answer

About 800 jobs remain. The queue received 1,000 jobs and workers finished 200. At 20 jobs per second and no new arrivals, the remaining work takes 40 seconds. If the queue delivers a job twice, use a stable key such as the photo ID and resize version so the worker can safely reuse or replace the same output.

Try the queue backlog simulator

Try the order-processing lab