Scale agents by sizing three things separately: worker concurrency (Little's law: tasks per second × seconds per task), model capacity (KV cache for every live context, plus token throughput), and sandbox capacity. Add a queue with backpressure and per-user quotas, then add model replicas behind a load balancer as GPU memory, not CPU, runs out.
- Concurrency formula
- Tasks in flight = arrival rate × task duration
- Usual first bottleneck
- Model KV cache and throughput
- KV cache, Qwen3 32B (FP16)
- ≈ 0.25 MB per token
- Scale-up option
- 1, 2, 4 or 8 GPUs in one machine
- Scale-out option
- Several model replicas behind a load balancer
- H200 for many long contexts
- 141 GB, $9.09/hr
An agent product that works for ten users can fall over at a hundred and become unaffordable at a thousand. The reasons are predictable: agents hold long contexts, run for minutes, and fan out into tools and sub-agents, so their load looks nothing like a chat app's. This guide gives you the sums to size each layer, the order in which things break, and what to add at each stage.
What actually limits how many agents you can run?
Three resources limit agent scale, and they run out at different times: worker concurrency, model capacity and sandbox capacity. Model capacity almost always runs out first and costs the most to add.
| Resource | What consumes it | Cost to add | Typical limit |
|---|---|---|---|
| Worker concurrency | One agent loop per task in flight | Very low (CPU, RAM) | Tens of loops per vCPU |
| Model capacity | Live contexts in KV cache; tokens per second | High (GPUs) or rate limits (APIs) | A few to a few dozen long contexts per GPU |
| Sandbox capacity | One environment per code-running task | Moderate (CPU, RAM, disk) | Memory per host |
| Data layer | Step logs, state, memory lookups | Low until very large | Postgres connection limits |
Scale is mostly the art of not letting the cheap layers flood the expensive one. The AI agent infrastructure guide introduces each layer.
How many agents will be running at once?
Use Little's law: tasks in flight = arrival rate × average task duration. It turns business numbers into a concurrency target.
Worked example: 2,000 active users, each starting 5 agent tasks on a working day, with 15% of the day's tasks landing in the busiest hour. Average task duration 4 minutes.
| Step | Formula | Result |
|---|---|---|
| Tasks per day | 2,000 × 5 | 10,000 |
| Peak-hour tasks | 10,000 × 15% | 1,500 |
| Arrival rate at peak | 1,500 ÷ 3,600 s | 0.42 tasks/s |
| Tasks in flight at peak | 0.42 × 240 s | ≈ 100 |
| Model calls per task | assumption | 12 |
| Model requests per second at peak | 1,500 × 12 ÷ 3,600 | 5 requests/s |
A hundred agent loops is easy for the worker layer: a couple of small servers. Five model requests a second, each with a long prompt, is where the planning starts.
How much model capacity do the agents need?
Model capacity has two parts: memory for every live context (the KV cache) and throughput for the tokens processed. Size both.
KV cache. KV per token = 2 × layers × KV heads × head dim × bytes. For Qwen3 32B (64 layers, 8 KV heads, head dim 128, FP16): 2 × 64 × 8 × 128 × 2 = 262,144 bytes ≈ 0.25 MB per token. Agents spend roughly half their time waiting on tools, so assume about half of the 100 in-flight tasks hold a live sequence at any moment.
| Quantity | Formula | Result |
|---|---|---|
| Live sequences at peak | 100 × 50% | 50 |
| Average context per live sequence | assumption | 12,000 tokens |
| KV tokens needed | 50 × 12,000 | 600,000 |
| KV memory, FP16 | 600,000 × 0.25 MB | ≈ 150 GB |
| KV memory, FP8 KV cache | half | ≈ 75 GB |
Per-GPU capacity, with ~18 GB of 4-bit weights and 15% headroom:
| GPU | VRAM | KV budget | KV tokens (FP8 cache) | GPUs for 600k tokens |
|---|---|---|---|---|
| L40S | 48 GB | ≈ 23 GB | ≈ 184,000 | 4 |
| H100 | 80 GB | ≈ 50 GB | ≈ 400,000 | 2 |
| RTX PRO 6000 | 96 GB | ≈ 64 GB | ≈ 512,000 | 2 |
| H200 | 141 GB | ≈ 102 GB | ≈ 816,000 | 1 |
These ignore prefix sharing, which helps when agents share long system prompts, and assume vLLM's paged KV cache, which wastes little. If KV runs out, vLLM queues or preempts requests rather than failing, so the symptom is latency rising at peak, not errors. More on the memory formula in how much GPU memory LLMs need.
Throughput. Check the token rate too: 5 requests a second × (say) 2,000 fresh prefill tokens each with caching = 10,000 prefill tokens/s, plus 5 × 300 = 1,500 decode tokens/s. Those are estimates for planning; run a load test with your real prompts against one replica, find its sustainable requests per second at acceptable latency, and divide.
Scale up or scale out?
Scale up (a bigger GPU, or several GPUs in one machine with tensor parallelism) when the model or its contexts don't fit. Scale out (more identical replicas behind a load balancer) when one replica fits comfortably but can't keep up.
Scaling up within one machine with vLLM:
# One model sharded across 4 GPUs in the same machine
vllm serve Qwen/Qwen3-32B-AWQ \
--tensor-parallel-size 4 \
--max-model-len 32768 \
--kv-cache-dtype fp8 \
--enable-prefix-caching \
--enable-auto-tool-choice --tool-call-parser hermes \
--api-key "$VLLM_API_KEY"Tensor parallelism pools the VRAM of the GPUs, so the KV budget grows roughly in proportion. See the vLLM distributed serving docs for your version. It works best over fast GPU-to-GPU links; on PCIe cards, for a model that already fits on one GPU, two or four independent replicas often give more throughput than one tensor-parallel replica. Test both.
Scaling out across replicas, using LiteLLM's router as an OpenAI-compatible front door:
model_list:
- model_name: agent-default
litellm_params:
model: openai/Qwen/Qwen3-32B-AWQ
api_base: os.environ/REPLICA_A_URL
api_key: os.environ/REPLICA_A_KEY
- model_name: agent-default
litellm_params:
model: openai/Qwen/Qwen3-32B-AWQ
api_base: os.environ/REPLICA_B_URL
api_key: os.environ/REPLICA_B_KEY
router_settings:
routing_strategy: least-busy
num_retries: 2Two entries with the same model_name become a pool; agents call agent-default and never know how many replicas exist. Replicas also give you redundancy: one can restart while the other serves. Prefer sticky routing per task when you can (send all of a task's calls to the same replica), because that is where its prefix cache lives. Machines on Wandering Giants take 1, 2, 4 or 8 of the same GPU, which covers either approach within a machine; across machines, the router above does the balancing. See multi-GPU cloud servers for options elsewhere.
How do you protect the model from overload?
Put a queue with backpressure between users and agents, and quotas between tenants and the queue. The model should see a steady flow it can serve, not every user's burst at once.
- Cap worker concurrency to model capacity. If your replicas sustain 100 tasks in flight, run 100 workers, not 500. Extra workers only make every task slower.
- Per-tenant concurrency limits. No single customer gets more than, say, 10% of the workers.
- Per-tenant budgets. A daily token or cost ceiling per customer, enforced before enqueueing.
- Priority queues. Interactive tasks (a user is waiting) ahead of batch tasks (overnight reports).
- Honest feedback. When queues are long, tell users the expected wait rather than timing out.
from redis import Redis
from rq import Queue
r = Redis.from_url("redis://localhost:6379/0")
interactive = Queue("agents-interactive", connection=r)
batch = Queue("agents-batch", connection=r)
def submit(tenant: str, task: str, interactive_task: bool, max_concurrent: int = 10):
key = f"inflight:{tenant}"
if int(r.get(key) or 0) >= max_concurrent:
raise RuntimeError("tenant at concurrency limit; retry later")
r.incr(key) # the job must DECR this key when it finishes or fails
q = interactive if interactive_task else batch
return q.enqueue("agent.run_agent", task, job_timeout=900)Workers listen in priority order with rq worker agents-interactive agents-batch, so batch jobs only run when no interactive job is waiting. In production, make the check-and-increment atomic (a Lua script or INCR then compare) and decrement in a finally block.
What changes at each stage of growth?
Each stage adds one or two pieces; nothing needs to be rebuilt if you started with an OpenAI-compatible model interface and a queue.
| Stage | Tasks in flight | Model layer | Workers and sandboxes | New concerns |
|---|---|---|---|---|
| 1–10 users | 1–5 | Hosted API or one small GPU | One process | Step limits, logging |
| 10–100 users | 5–20 | One L40S or H100 replica | Queue + a few workers, one sandbox host | Budgets, retries, tracing |
| 100–1,000 users | 20–100 | 2–4 replicas or one large-memory GPU | Worker pool, sandbox fleet or service | Tenant quotas, priority queues, load tests |
| 1,000+ users | 100+ | Replica pools per model, frontier API for hard steps | Autoscaled CPU tier | Capacity planning, multi-region, cost per tenant |
The CPU tier (workers, sandboxes) can use whatever autoscaling your usual cloud offers. The GPU tier is usually added in planned steps. Serverless GPU platforms (Modal, RunPod Serverless, Baseten) do autoscale model endpoints and are a good fit for very spiky load; the trade-off is cold starts measured in tens of seconds to minutes while weights load, which agents feel on every scale-up. Wandering Giants does not offer autoscaling; for steady agent traffic, a warm fixed fleet sized for peak, with spare machines stopped by the minute outside working hours, is usually simpler and keeps the prefix cache hot.
How does cost scale with users?
On a hosted API, cost scales linearly with tasks. On your own GPUs, cost scales in steps with peak capacity, and cost per task falls as utilisation rises.
Using the example above (10,000 tasks a day, peak needing 2 H100s at FP8 KV cache):
| Approach | GPU-hours a day | Cost a day | Cost per task |
|---|---|---|---|
| 2 × H100 running 24 h | 48 | 48 × $4.99/hr ≈ $239.52 | $0.024 (48 GPU-hours ÷ 10,000 tasks) |
| 2 × H100 for 12 working hours, 1 overnight | 24 + 12 = 36 | 36 × $4.99/hr ≈ $179.64 | $0.018 (36 GPU-hours ÷ 10,000 tasks) |
| 1 × H200 for 12 h, stopped overnight (batch tasks moved into the day) | 12 | 12 × $9.09/hr ≈ $109.08 | $0.0109 (12 GPU-hours ÷ 10,000 tasks) |
The last row shows the lever that matters most: shaping load so the GPUs you pay for are busy. Moving batch tasks into working hours, or running them in one dense overnight window on fewer GPUs, cuts GPU-hours far more than shaving model size does. Compare the per-task figure with your hosted API's tokens × price to decide where each kind of task should go; the tutorial on running agents in the cloud shows how to collect the token counts. For multi-agent workloads, where fan-out raises tokens per task, see multi-agent infrastructure.
When does Wandering Giants fit a scaling agent product?
It fits the model tier while it grows in planned steps. Each API machine on Wandering Giants Compute is a private OpenAI-compatible endpoint; put two or more behind a router like the one above and you have a replica pool. Machines hold 1, 2, 4 or 8 of the same GPU, from a 48 GB L40S to a 141 GB H200 or a 288 GB B300, billed by the minute so overnight capacity can be switched off. It doesn't fit if you need autoscaling, multi-node clusters or an uptime SLA; providers that offer those are named in our comparisons. See GPUs and prices.
Frequently asked questions
What is the first thing to break when scaling AI agents?
Usually the model layer: hosted API rate limits, or on your own GPU, the KV cache filling up so that requests queue. Worker processes and sandboxes are cheap to add; model capacity is the expensive, slow-to-add resource.
How many concurrent agents can one GPU serve?
It depends on model size and context length. A 32B model at 4-bit on a 48 GB L40S holds roughly 92,000 tokens of FP16 KV cache, about seven agents at 12,000 tokens each holding a live context; an H200 holds about 34. Agents waiting on tools don't hold a slot, so real concurrency is higher.
Do I need autoscaling for AI agents?
Not at first. Agent traffic is usually steady within working hours, and a queue absorbs short peaks. Autoscaling helps with very spiky traffic; serverless GPU platforms such as Modal and RunPod Serverless offer it, at the cost of cold starts when a model loads.
How do I stop one user from using all the agent capacity?
Put per-user or per-tenant quotas in front of the queue: a cap on concurrent tasks and a daily token or cost budget. Then use fair scheduling between tenants so one heavy user waits in their own line instead of everyone's.
Should I scale up to a bigger GPU or out to more GPUs?
Scale up when a model or its contexts don't fit, or when you need more KV cache per replica. Scale out with more identical replicas when one replica fits comfortably but can't keep up. Replicas also give you redundancy, which a single larger GPU does not.
Rent the GPU for this, by the minute.
Add model capacity in clear steps: launch 1 to 8 GPUs in one machine, each with a private OpenAI-compatible endpoint, billed by the minute.
Prepaid credit, billed by the minute, stops itself when credit runs out. Prices in £, $, €, ¥, CA$, A$, CHF and S$; UK prices include VAT.
Keep reading
- Complete guideWhat Is AI Agent Infrastructure? A Complete Guide
- GuideHow to Build Infrastructure for Multi-Agent AI Systems
- TutorialHow to Run Autonomous AI Agents on Cloud Infrastructure
- GuideHow Much GPU Memory Do You Need to Run LLMs?
- ComparisonBest Cloud Providers for Multi-GPU Servers
- GuideWhy AI Agents Need Their Own Computers and Execution Environments
About this article. Written by the Wandering Giants Compute team, the people who run Wandering Giants Compute. Hardware figures are the manufacturers’ published specifications. Speeds and costs marked as estimates are worked out from those specifications and our current prices, with the method shown; they are not measured benchmarks. Wandering Giants prices are taken live from our price list each time this page is built.
Last reviewed 25 November 2026.