36/41
Part 6 of 7 · Overload and monitoringLearn and do

Watch the queue's age, not just the errors

The last piece is knowing when something is wrong.

Queue age shows what errors and latency hide

Hour123456
GPU utilization95%95%95%95%95%95%
error rate0.1%0.1%0.1%0.1%0.1%0.1%
oldest queued0.5 h1.4 h2.3 h3.2 h4.1 h5.0 h

Error rate and GPU utilization can both look healthy while a batch service quietly misses its promise. Only the last row shows it.

Start where the Builders' Library does for queue-based systems: measure the age of the messages in the queue.

Backlogs are dangerous because draining one takes spare capacity you may not have. After an hour-long outage, recovering takes double the system's capacity for another hour.

Latency graphs can mislead too:

10 requests: 6 shed in 1 ms, 4 served in 5 sMedian
all 101 mslooks amazing
the 4 served5 swhat customers get

Shed requests fail fast, and fast failures pull latency graphs down. The load-shedding article gives the example: a service shedding 60% of its traffic can show an amazing median latency while its successful requests are terribly slow. Graph successful-request latency on its own.

In the editor, write oldest_age(queued_at, now): the age of the oldest request still queued, 0 for an empty queue. Then write served_median(requests): the median latency of only the requests that were served. The print line is the 10-request table.