
Load shedding for AI workflows: reject work before overload wins
Learn how to shed low-value AI work before overload collapses useful throughput, while preserving fairness, auditability and safe recovery.
Load shedding for AI workflows means deliberately refusing, deferring or reducing work before overload destroys the useful throughput of the whole system. It is not an admission that the architecture failed. It is the mechanism that keeps a capacity problem from becoming a reliability incident.
A conventional API usually sees one request and produces one response. An agent can turn one request into a plan, five parallel searches, three model calls, a browser session and several tool writes. A retry or re-plan can multiply that tree again. By the time CPU or provider rate limits look critical, the workflow may already have accepted far more future work than it can complete while the result is still useful.
I design shedding at the workflow boundary, where the system still knows the user, intent, deadline, estimated cost and consequence of refusal. The goal is not to keep every run. The goal is to preserve the most useful outcomes, fail explicitly and recover without creating a second traffic wave.
What load shedding means for an AI workflow
Load shedding is the controlled removal of excess demand. When a system approaches saturation, it stops accepting some work so the work it does accept can still finish within its service objective. Amazon's Builders' Library describes the objective in terms of goodput: requests completed successfully and quickly enough for the caller to use the response, rather than raw throughput alone.
For an agent, the unit being protected should normally be a useful workflow outcome, not an individual HTTP call. Rejecting one tool request after a run has already paid for planning and retrieval may save the dependency while still wasting most of the run. Admission has to happen at multiple boundaries:
- Run admission: should this user intent enter the system now?
- Stage admission: should the run start an expensive model, browser or retrieval stage?
- Fan-out admission: how many parallel branches may this run create?
- Side-effect admission: is there enough time and capacity to complete and verify an external action safely?
These decisions differ from a rate limit. A rate limit controls how quickly demand may arrive. A concurrency limit bounds simultaneous work. Backpressure decides how producers react to unavailable capacity. Load shedding is the final policy decision that some offered work will not run in its requested form.
Why agents make overload harder
Agent load is not proportional to request count. Two requests can have the same endpoint and radically different cost. One may answer from a cached document in a single model call. Another may search the web, inspect ten pages, execute code and loop after a tool returns ambiguous data.
Five properties make agent overload especially dangerous:
- Fan-out: one accepted run creates many downstream operations.
- Variable cost: prompt length, model choice, tool latency and plan depth change resource use.
- Positive feedback: timeouts trigger retries or re-planning while the dependency is already slow.
- Late uselessness: a technically successful answer can arrive after the user, approval or source state has moved on.
- Mixed scarcity: the bottleneck may be model concurrency, tokens per minute, browser slots, database connections or a vendor quota.
A deep queue hides this problem rather than solving it. It converts immediate excess demand into latency and a future capacity obligation. Expiry removes jobs after they lose value; shedding prevents the system from accepting an obligation it already knows it cannot meet.
The safest excess request is the one rejected before it creates a plan, reserves a model slot or touches an external system.
Choose signals that represent real capacity
CPU alone is rarely an adequate admission signal for AI workflows. An application server can be mostly idle while every permitted model call is in flight and the provider's token budget is exhausted. Queue length alone is also weak: ten small classification jobs and ten research agents are not equivalent demand.
I use a small capacity vector rather than a single “system busy” flag:
| Signal | What it protects | Useful form |
|---|---|---|
| Active run permits | Worker and orchestration capacity | Used / hard limit by workload class |
| Model permits | Provider concurrency | In-flight calls by model and tenant |
| Token budget | Tokens per minute and spend | Reserved plus actual tokens in a rolling window |
| Queue age | Latency objective | Oldest useful job, not just queue depth |
| Dependency health | Tool and storage stability | Latency, timeout and rejection trends |
| Deadline slack | Result usefulness | Deadline minus conservative remaining duration |
Reservation matters. If admission considers only completed token usage, twenty runs can pass the check at once and collectively exceed the next minute's budget. Reserve a conservative estimate atomically, reconcile it with actual usage after each stage and release unused capacity. Estimation will be imperfect, so protect it with a hard global ceiling.
Use recent dependency behavior rather than waiting for total failure. Rising tail latency and timeouts reduce effective capacity before an explicit rate-limit response arrives. The admission controller should close quickly when health deteriorates and reopen gradually when it recovers.
Make the shedding decision before expensive work
The first admission check belongs immediately after cheap authentication, validation and idempotency lookup. At that point the system should know enough to classify the request without building a full plan. It can calculate a workload class, tenant, deadline, rough cost band and whether an existing result or in-progress run can satisfy the same intent.
Check again before each expensive phase because conditions change while a workflow waits. A run admitted with thirty seconds of deadline slack may have none left after retrieval. A provider may become unhealthy between planning and execution. Stage-level admission prevents a previously valid decision from becoming permanent permission.
The check must be cheap and local enough to remain available during overload. An admission service that performs multiple synchronous database queries and a model-based priority classification becomes another bottleneck. Precompute policy attributes, keep hot counters close to the workers and define a conservative fallback when shared state is unavailable.
Build a policy from value, cost and urgency
First come, first served is simple but usually wrong under pressure. A nightly re-indexing run can consume the final model permit while a user waits for an approved customer response. A high-paying tenant should not be able to starve everyone else by opening enough parallel agents either.
A practical admission envelope contains:
- Criticality: what user or business harm follows if the run does not execute now?
- Deadline: when does starting or finishing stop being useful?
- Estimated cost: model calls, reserved tokens, tool operations and expected duration.
- Tenant share: how much protected capacity this customer or workload has already consumed.
- Degradation options: whether a cheaper, cached or narrower result still satisfies the contract.
- Safety class: whether interruption could leave an external side effect unresolved.
Keep the number of service classes small enough that operators can explain them. Google SRE describes propagating a small criticality vocabulary through RPC systems so overloaded dependencies shed lower-criticality work first. The same idea fits agents if criticality follows every branch and a child cannot silently promote itself above its parent.
Do not let users directly select “critical.” Derive it from an authenticated product action and an explicit policy. Otherwise every caller will rationally mark every request as essential.
Reject, defer, degrade or coalesce
Shedding does not always mean returning an error. The correct outcome depends on whether the work will retain value and whether the product can offer a smaller promise.
| Outcome | Use it when | Contract |
|---|---|---|
| Reject | The request is interactive or already lacks deadline slack | Return an explicit overloaded response without creating a run |
| Defer | The work remains valuable later and the queue is bounded | Persist a next eligible time and expiry |
| Degrade | A cheaper result still provides honest value | Label the reduced mode in the response and audit trail |
| Coalesce | Several requests ask for the same current result | Attach demand to one in-progress run |
| Serve cached | Freshness tolerance permits a previous result | Expose its timestamp and provenance |
Degradation must be designed before the incident. Examples include searching fewer sources, using an approved smaller model, skipping optional enrichment or returning an existing summary with its age. Never silently remove a safety check, approval step, source citation or reconciliation phase to save capacity.
A deferred run needs a bound. Without next_eligible_at and latest_start_at, deferral becomes an unbounded queue that restarts the overload later. Combine it with priority scheduling that guarantees progress for lower classes.
Propagate the decision through the workflow
One admitted agent should not get unlimited permission to create children. Carry an execution envelope through every stage:
{
"run_id": "run_7f3a",
"tenant_id": "tenant_42",
"criticality": "interactive",
"latest_finish_at": "2026-11-27T08:00:30Z",
"token_budget_remaining": 18000,
"tool_calls_remaining": 12,
"max_parallel_branches": 3,
"degradation_mode": "standard"
}
Every branch spends from the same parent budget. Re-planning does not reset counters. A child inherits the parent's deadline and criticality unless a trusted policy explicitly lowers them. This prevents fan-out from bypassing the control that admitted the original request.
If a stage is shed, record a domain outcome such as rejected_overload, deferred_capacity or completed_degraded. Do not throw every case into a generic failed-job queue. Operators and product teams need to distinguish infrastructure errors from intentional capacity decisions.
Implement admission control in Laravel
In Laravel, admission can sit in an application service before dispatch. The database owns the durable run and outcome; a fast shared counter can protect scarce execution capacity. The key is to make reservation and run creation one logical decision.
final class AdmitAgentRun
{
public function __construct(
private CapacityGate $capacity,
private RunRepository $runs,
) {}
public function handle(StartAgentRun $command): AdmissionResult
{
$intent = WorkloadIntent::from($command);
if ($existing = $this->runs->findEquivalentActiveRun($intent)) {
return AdmissionResult::coalesced($existing->id);
}
$estimate = CapacityEstimate::for($intent);
$reservation = $this->capacity->tryReserve(
tenant: $intent->tenantId,
class: $intent->serviceClass,
tokens: $estimate->tokens,
permits: $estimate->permits,
expiresAt: $intent->latestStartAt,
);
if ($reservation === null) {
return $intent->mayDefer()
? AdmissionResult::deferred($intent->nextEligibleAt())
: AdmissionResult::rejected('capacity_unavailable');
}
try {
$run = $this->runs->createAccepted($intent, $reservation);
ExecuteAgentRun::dispatch($run->id);
return AdmissionResult::accepted($run->id);
} catch (Throwable $error) {
$this->capacity->release($reservation->id);
throw $error;
}
}
}
A production implementation also needs reservation expiry in case dispatch fails after persistence, idempotent release, reconciliation against provider usage and a sweeper for abandoned permits. If the queue and database cannot commit atomically, use a transactional outbox so an accepted run is eventually dispatched without creating a ghost reservation.
Return an overload response the caller can understand. For synchronous HTTP, that may be 429 for a customer quota or 503 for temporary global capacity, with a truthful retry hint only when the server can estimate one. For asynchronous APIs, expose the explicit admission result rather than pretending every submitted run is queued.
Protect tenants and background work
A global ceiling protects infrastructure but not fairness. One tenant can consume every permit before others arrive. Use hierarchical limits: a hard global bound, reserved shares for important workload classes, and per-tenant ceilings with controlled borrowing when capacity is idle.
Borrowing improves utilization, but borrowed capacity must be reclaimable for new admissions. Do not interrupt an irreversible external action merely to reclaim it. Reclaim at safe stage boundaries and keep headroom for reconciliation, cancellation and health checks.
Background work also needs a progress guarantee. If interactive demand can consume 100 percent of capacity forever, batch queues never drain. Reserve a small floor, use weighted scheduling or define an age threshold that gradually increases effective priority. Fairness is a product decision expressed as capacity policy.
Measure goodput, not busy workers
Worker utilization can look excellent during a collapse. The system may be busy processing attempts whose callers have timed out. Measure outcomes that still had value:
- accepted runs completed before their deadline;
- goodput by tenant and service class;
- rejections, deferrals, degradations and coalesced requests by reason;
- false shedding: rejected work when protected capacity was actually available;
- reserved versus actual tokens, duration and tool calls;
- queue age and deadline slack at every stage;
- retry amplification and fan-out per accepted run;
- recovery time after offered load returns to normal.
Keep fast rejection latency out of successful-run latency percentiles. Otherwise a wave of immediate rejections can make the dashboard claim that median latency improved. Plot offered demand, admitted demand, rejected demand and useful completions together.
Test beyond the capacity boundary
A load test that stops at expected peak traffic does not verify shedding. Increase offered demand past saturation and keep increasing it. Useful completions should plateau rather than fall toward zero, accepted-run latency should remain bounded and rejection should stay cheap.
Test more than uniform requests:
- mix short classifications with expensive research agents;
- slow one model or tool dependency while traffic remains constant;
- trigger retryable errors and confirm retries cannot bypass admission;
- send a noisy tenant alongside normal tenants and verify isolation;
- exhaust browser slots while model capacity remains available;
- restore capacity and confirm deferred work returns gradually, not as a stampede;
- disable the capacity store and verify the conservative fallback.
Amazon recommends testing well beyond the breaking point because overload behavior determines whether goodput plateaus or collapses. For agents, the same test must include the full call graph. A gateway can remain healthy while downstream model and tool calls multiply out of control.
Production checklist
- Define the useful outcome and deadline for every workload class.
- Estimate and reserve scarce capacity before creating expensive work.
- Bound fan-out, retries, tokens and tool calls within one run envelope.
- Use a small authenticated criticality vocabulary and propagate it.
- Design explicit reject, defer, degrade, cache and coalesce outcomes.
- Never degrade safety, approval or side-effect reconciliation.
- Apply global, service-class and tenant-level fairness controls.
- Record shedding as an auditable workflow transition.
- Measure useful completions and false shedding separately.
- Load-test past saturation and verify recovery without a stampede.
Load shedding is not the last emergency switch after queues, autoscaling and retries fail. It is part of the product contract for finite capacity. A reliable AI workflow knows which work it can promise, which work can wait and which work it must refuse before overload makes that decision accidentally.
If your agent platform keeps accepting work while model latency, queues or tool failures climb, I can help review its admission boundaries and capacity policy. See my AI engineering consulting work or contact me.
Sources
- Amazon Builders' Library: Using load shedding to avoid overload
- Google SRE Book: Handling Overload
- Google SRE Book: Addressing Cascading Failures
- Laravel 13.x documentation: Queues
Sources and methodology: sources checked November 27, 2026. The workflow admission envelope, stage-level decision model and Laravel example are original synthesis based on production-oriented PHP, queue and AI-agent engineering. Exact thresholds and service classes must be validated against each workload. This article was prepared with AI assistance and reviewed for technical accuracy and practical usefulness. Cover: network infrastructure photograph from Pixabay.
