Lesson 2 of 4
Reserve Capacity for the Slow Lane
Estimated time: 10 minutes
Hold workers back for the quiet lane
Changing the ordering is one lever. Deciding who may occupy a worker at all is another, and it is the stronger one. A schedule that always prefers the loud lane will starve the quiet lane no matter how the ordering is calculated.
Hold a slice of the worker pool for quiet work, and refuse to let the loud lane borrow it. During a surge this is the only rule that keeps both lanes moving, because a surge is precisely when everything else would be handed over.
def next_lane(pool, held):
if pool.quiet_waiting and pool.busy_quiet < held:
return "quiet"
return "loud"
Watch the age of the oldest item in each lane. A single overall figure tells you how much work is waiting and nothing about how long the oldest piece has been waiting. A shallow queue can hide a request that has been ignored since morning.
Re-examine the held number when traffic patterns change. A slice that was generous last year can become the reason the quiet lane never runs.