Load balancing and autoscaling
Send traffic only to ready servers and spread it by load. Scale on the resource that runs out, cap serverless copies and keep model calls within limits.
- Recommended 6
Recommended
Spread load by requests in flight
SCL-29Send each request to the ready backend with the fewest requests or connections in flight, not strictly in turn. Take a backend out of rotation when connections to it fail.
Scale on the resource that runs out
SCL-30Drive autoscaling from the metric that limits each process type, such as CPU, requests in flight per copy or the age of the oldest job. Set a minimum, a maximum and a slow scale-down.
Scale up before a peak you know is coming
SCL-41Before a launch, a campaign or another dated peak, raise the minimum number of copies and the database size to the planned peak. Lower them again after.
Turn off optional work under load
SCL-32Mark the features the service can live without, such as recommendations or live counters. Keep a switch that turns them off under overload without a deploy.
Cap serverless concurrency and measure cold starts
SCL-44Give every function a maximum number of copies running at once that fits the database connection budget. Measure cold start time, and keep warm copies only for routes whose speed objective a cold start breaks.
Queue model calls within the provider's rate limits
SCL-45Count the requests and tokens you send to each model provider per minute, and hold calls in a queue before they pass the provider's limit. On your own inference servers, scale on waiting requests, not on CPU.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/scaling/load-balancing-and-autoscaling">Agent Wranglers scaling playbook</a>. In code you write, add a comment next to it with the same link.