Shed in an order that protects goodput
Under overload, throughput is the wrong number. The Builders' Library article on load shedding defines goodput as the part of throughput handled without errors and soon enough for the client to use the response.
For a batch service, goodput is tokens from requests that succeed inside the window. Duplicates, recompute after preemption and work on requests that expire anyway are all waste.
Shed in an order that protects goodput:
- Stop granting new batch leases before interactive traffic feels anything.
- Within batch, defer the work furthest from its deadline.
- Finish what was started. Evicting a sequence that is 90% done throws away 90% of its cost. The load-shedding article makes the same point with a service that has
start()andend()calls: it should serve theend()calls first.
The curve below is the 8-worker queue from the design round lesson. It starts at 95% load: say 70% from people and 25% from batch, all in one first-come queue. That's what a design without priorities builds.
Everyone's p99, the latency 99% of requests beat, is about 4.9 seconds.
Drag the load down to 70%, roughly what interactive requests see when batch is preempted first. The p99 falls to about 1.9 seconds.
Batch was the 25% that pushed everyone into the knee, and it's the 25% that can wait. For batch, shed only means later.
- Served per second
- 19.0
- p50
- 964 ms
- p99
- 4.9 s
- Waiting, on average
- 16.0
In the editor, write shed_order(work): the ids in the order to shed them. Each item says whether it started, the hours left to its deadline, and the share done. Shed what hasn't started first, furthest from its deadline first, then running work, least done first.