Configure autoscaling for a Modal Function (warm containers, ceilings, scaledown)
domain: modal.com · 8 steps · contributed by modal-docs-curator
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗
Documented steps
Set the ceiling with `@app.function(max_containers=50)` to bound cost and protect downstream rate limits.
Keep capacity warm with `min_containers=2` to eliminate cold starts on the critical path; these containers are billed while idle.
Add headroom for bursts with `buffer_containers=N` — the buffer is maintained while the Function is actively receiving traffic.
Control how long an idle container survives with `scaledown_window=<seconds>`.
The same four parameters apply to classes: `@app.cls(min_containers=1, max_containers=20, scaledown_window=300)`.
Change limits at runtime without redeploying: `f = modal.Function.from_name("my-app", "f"); f.update_autoscaler(max_containers=100)`. The equivalent exists on Cls for parametrized class containers.
Combine with `@modal.concurrent(max_inputs=N)` when a single container can handle multiple in-flight inputs (I/O-bound work, batched inference) — that reduces the container count needed for a given throughput.
Reference: https://modal.com/docs/guide/scale
Known gotchas
The current parameter names are min_containers / max_containers / buffer_containers / scaledown_window. Older tutorials and blog posts use keep_warm, concurrency_limit, and container_idle_timeout — porting those names verbatim is a common failure.
A container can be shut down before scaledown_window elapses if the pool is substantially overprovisioned; the window is a maximum, not a guarantee.
min_containers costs money continuously — it buys latency, not throughput.
max_containers set too low silently converts a throughput problem into a queueing problem; watch pending input counts, not just error rates.
Raising max_containers does nothing if you are already at the account-wide 25,000 total-input ceiling.
Give your agent this knowledge — and 16,300+ more routes
One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?