Stage 1 of 9 · Model
What the numbers say
Use 86,400 seconds in a day, and about 2 KB per job.
What you need to know first
A day has 86,400 seconds. Divide a daily total by 86,400 to get the average per second, then compare it with the peak to see how spiky the traffic is.
1.4 billion jobs a day. About how many jobs a second is that on average?
About 16,200 per second.
1,400,000,000 ÷ 86,400 ≈ 16,200 a second. The 33,000 peak is about twice that.
A queue holds the difference between what arrives and what is finished. If workers keep up, the queue stays near empty. If they slow down, the backlog grows by (arrival rate − completion rate) every second, for as long as that lasts.
So the question for any buffer is: how long a bad period can it hold, and what does that cost?
Workers stop completely for 10 minutes at the 33,000-a-second peak. Jobs are about 2 KB. About how many gigabytes of jobs pile up?
About 40 GB.
33,000 × 600 seconds ≈ 20 million jobs. 20 million × 2 KB ≈ 40 GB.
On disk, 40 GB is nothing. In RAM, it's 40 GB of headroom you have to keep free on every normal day, just in case.
Where is it cheapest to hold a backlog that might reach 40 GB a few times a year?
A disk-backed log
Disk costs a small fraction of RAM per gigabyte, and a log written sequentially is fast enough to absorb 33,000 jobs a second. Memory is best kept for the small set of jobs workers are about to take.
What the stage asks
Which statements follow?
- Holds
1.4 billion jobs a day is about 16,000 jobs a second on average, so the peak is about twice the average.
1,400,000,000 / 86,400 ≈ 16,200. The 33,000 a second peak is about 2×.
- Holds
If workers stop completely for ten minutes at peak, about 20 million jobs pile up, roughly 40 GB.
33,000 × 600 ≈ 19.8 million jobs; at 2 KB each, about 40 GB. In RAM, that is a lot of headroom to keep permanently free for a bad ten minutes.
- Fails
A queue lets producers outpace consumers indefinitely.
A queue absorbs bursts. If arrivals stay above completions, the backlog grows until something runs out. See Backpressure and capacity.
- Fails
Since Redis is in memory, it is the best place to hold a large backlog.
Memory is the most expensive and least elastic place to hold a backlog. A disk-backed log holds days of jobs cheaply; memory is for the small working set workers are about to take.
The reasoning
- A backlog grows by arrivals minus completions per second; size buffers for the worst period you expect.
- Hold large backlogs on disk; keep memory for the small working set workers are about to take.
- A queue absorbs bursts; it can't make producers outpace consumers forever.
A job queue has two jobs that pull in different directions: hand work to workers quickly (which suits memory) and hold a backlog safely when workers fall behind (which suits disk). The original design asked Redis to do both, so its worst day was decided by how much RAM happened to be free.