Load shedding and admission
Design bounded admission around resource cost, deadlines, and tenant fairness instead of allowing overload to consume the service.
On this page
The question for today
What you’ll understand
- Calculate an admission limit from a measured bottleneck resource.
- Distinguish a rate limit, concurrency limit, and queue bound.
- Design a recovery policy that protects useful throughput and tenant isolation.
An overloaded service can spend its entire capacity on work that will miss its deadline. The goal of admission control is to preserve useful completed operations by refusing or deferring work before it consumes scarce resources. A practical policy must identify the bottleneck, account for variable request cost, and preserve the contract for different callers. Rejection itself has a cost, and a poorly designed queue or retry policy can turn protection into another source of overload.
Admit a resource budget, not an arbitrary request count
A request rate is meaningful only relative to a workload distribution. Ten short cache hits and ten long generation requests can impose very different CPU, accelerator-memory, and connection costs. Measure resource service demand by request class and use a conservative operating envelope validated under realistic bursts. If a node has eight cores, a budget of six CPU-seconds per second leaves nominal headroom, but memory or storage may still bind first. Protect every resource whose exhaustion changes the service's behavior materially.
A token bucket allows a sustained rate with bounded bursts; a concurrency limiter bounds simultaneous in-flight work; a bounded queue limits waiting work. These controls address different failure mechanisms. A rate limit alone does not prevent concurrency from growing when service times lengthen. A concurrency limit without tenant accounting can let one slow workload occupy every slot. Apply inexpensive checks early, make reserved and shared capacity explicit, and define whether excess work is rejected, scheduled later, or placed in a durable queue.
Bound waiting by the remaining useful deadline
Work should not wait indefinitely merely because a queue has space. Compare estimated waiting and processing time with the remaining end-to-end deadline, and decline work that cannot usefully finish. The estimates have uncertainty, so measure missed deadlines and adjust conservatively. A rough queue bound can start from a tolerated waiting interval times measured completion rate, then be tested against the actual service-time distribution. Queue length is not interchangeable with queue age, especially when request costs vary or scheduling prioritizes particular classes.
Separate critical operations from work that may be delayed, but prevent callers from assigning themselves unlimited priority. Derive criticality at a trusted boundary and propagate it consistently. Reserve recovery capacity for health checks, cancellation, control traffic, and administrative access; otherwise overload may disable the very mechanisms needed to repair it. Reject cheaply where possible, return an actionable overload signal, and coordinate retry behavior. An upstream caller that immediately resubmits every rejection can consume CPU and network resources without increasing useful work.
Recover without oscillation
An adaptive limiter needs a stable signal and a controlled response. Raising a limit after one fast sample and lowering it after one slow sample can oscillate, especially with delayed metrics. Test smoothing, minimum observation windows, separate increase and decrease behavior, and hysteresis around operating thresholds. Do not tune only at steady load: exercise a burst, dependency slowdown, client retry wave, and return to normal. Record how quickly useful throughput recovers and whether tenants with short inexpensive work remain protected.
The queue lab exposes one basic conservation law: when arrivals exceed service capacity, fluid backlog grows at their difference until arrivals fall or capacity rises. It begins with four waiting units and clamps the backlog at zero. Its separate M/M/1 mean residence time assumes Poisson arrivals and exponential independent service, so it is not a production admission controller. Use the lab to calculate drain time, then explain which measured cost classes, fairness rules, and deadlines a real implementation must add.
Work it through
Turn CPU headroom into an initial admission envelope
A measured homogeneous workload averages 0.006 CPU-seconds per request. A node reserves six CPU-seconds/s for admitted work. A separate load test measures 900 completions/s while meeting the latency target. Plan a queue for at most 40 ms of waiting.
The average CPU constraint gives an initial ceiling of 6/0.006 = 1,000 requests/s before other bottlenecks and bursts.
The latency-tested rate is lower, so start from the measured 900 requests/s envelope rather than claiming the average ceiling meets the target.
The rough queue plan is 900 × 0.040 = 36 requests. Test queue age and deadline misses under bursts before adopting this bound.
An initial policy admits no more than the tested envelope and bounds waiting near 36 requests for this workload. Different request costs require revised accounting, not a universal 900 requests/s rule.
The living notebook
Explore the model
Interactive lab · queue
Admission and backlog conservation
Vary λ and μ to inspect deterministic fluid backlog max(0, 4 + (λ − μ)t). The separate M/M/1 mean residence readout applies only when λ < μ under its stated arrival and service assumptions.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA finite queue protects memory, while useful admission still needs measured costs, deadlines, and fairness.
Pause & reason
Check your understanding
Your turn
Try it yourself
A service has 12 CPU-seconds/s available for an admitted request class averaging 0.008 CPU-seconds each. A latency test validates only 1,200 completions/s. Calculate the average resource ceiling and a planning queue bound for 25 ms waiting at the validated rate.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use resource budget divided by cost for the first quantity, and tested completion rate times waiting budget for the second.
Compare with the solution
The average CPU ceiling is 12/0.008 = 1,500 requests/s. The tested latency envelope is 1,200 requests/s, which should constrain an initial policy. The rough queue bound is 1,200 × 0.025 = 30 requests. None of these averages proves a latency percentile; validate bursts, service-time tails, cancellation, and resource contention.
Keep the idea
Take it with you
- Admission protects useful work by budgeting the resources requests actually consume.
- Rate, concurrency, queue length, and queue age are distinct controls.
- Test overload recovery and fairness as carefully as steady-state throughput.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.