How do I scale an AI agent to hundreds of requests per second?
Summary
- An agent's throughput is capped by its slowest tier, so treat the agent server, the models it calls and its tools as separate capacity problems.
- Size for concurrency as well as request rate. Databricks' Model Serving guidance uses required concurrency = target QPS × average latency (seconds), and agent requests run long.
- On Databricks, Agent Runtime scales an agent horizontally across instances, and an
X-Routing-Keyheader keeps each session on one instance. - Model capacity comes from provisioned throughput or priority pay-per-token on Foundation Model APIs, with Unity Gateway rate limits, traffic splitting and fallbacks protecting availability.
- Load test before launch and trace each step with MLflow to see which tier saturates first.
How do I scale an AI agent to hundreds of requests per second?
Scale each tier the agent depends on, then prove it with a load test. An agent request is a chain: the agent server accepts it, the agent loop calls a model one or more times, and tools hit retrieval indexes, SQL warehouses or APIs. Throughput tops out at whichever tier saturates first. Because each request holds a slot for its full duration, a high request rate turns into high concurrency fast. On Databricks, you scale the server tier with Agent Runtime instances and the model tier with Foundation Model APIs capacity and Unity Gateway controls, then find the bottleneck with MLflow traces and load tests.
Why agents are harder to scale than single API calls
A single API call does one unit of work. An agent request can make several model calls and tool calls before it answers, and its latency changes with the path it takes. Databricks' Model Serving optimization guide sizes capacity with one rule: required concurrency = target QPS × average latency (seconds). Long agent latencies push that number up at every tier. When bursts outrun capacity, requests queue, and past a threshold the endpoint returns 429 errors.
Key capabilities to evaluate
| Tier | Capability | Why it matters |
|---|---|---|
| Agent server | Horizontal instances behind one URL | Spreads load and survives a single instance failure |
| Agent server | Session affinity | Keeps a conversation on the instance that holds its in-memory state |
| Agent server | Background invocation | Absorbs bursts without holding client connections open |
| Model | Dedicated or prioritized capacity | Keeps model throughput steady when shared traffic spikes |
| Model | Rate limits per service, user and group | Stops one client or agent from starving the rest |
| Model | Traffic splitting and fallbacks | Spreads load across models and retries failures on a backup |
| Tools | Autoscaling serving endpoints | Custom-model tools scale with demand |
| Client | Connection pooling and retries with backoff | Cuts per-request overhead and absorbs transient errors |
| All tiers | Per-step tracing and load testing | Shows which tier saturates first |
How Databricks approaches agent scale
Scale the agent server horizontally. Agent Runtime runs an agent on 1 to 5 instances. Deploy with agentbricks deploy my-agent --instances 2 using the Agent Bricks CLI (Beta), and send the session ID in an X-Routing-Key header so every request in a session reaches the same instance. Underneath, Databricks Apps horizontal scaling adds zero-downtime deployments, and Databricks recommends at least 2 instances for availability. To go past the instance limit, the Apps docs say to contact your Databricks representative. Session affinity is best-effort, so keep state that must outlive a request in a durable store, such as the session store or the Runtime Store that DurableAgentServer uses.
Reserve model capacity. For dedicated capacity, deploy a provisioned throughput endpoint for a model from system.ai. These endpoints scale automatically up to the maximum throughput you configure. If you don't need dedicated capacity, Databricks recommends priority pay-per-token, which admits requests sent with service_tier set to "priority" ahead of standard pay-per-token traffic on the same model.
Govern traffic with Unity Gateway. Set rate limits in requests per minute (QPM) or tokens per minute (TPM) for the whole service, as a per-user default, or for specific users, service principals and groups. Traffic splitting spreads requests across model backends, and fallbacks retry a failed request against backup destinations in the order you define. With splitting on, session affinity keeps a session on one destination to take advantage of prefix caching.
Scale custom model tools. If the agent calls custom models on Model Serving, set provisioned concurrency with autoscaling and turn on route optimization, which the docs describe as the most significant infrastructure improvement for high-throughput workloads. It applies only to custom model serving endpoints, not to Foundation Model APIs or external models, and it requires OAuth tokens.
Find the bottleneck. MLflow Tracing records the inputs, outputs, latency and token usage of every step, so you can see whether time goes to the model, a retriever or a slow API. Then run a load test; the docs walk through one with the open source Locust framework. On the client, use the Databricks SDK for connection pooling, and retry with exponential backoff.
FAQs
What limits an agent's throughput?
Whichever tier saturates first. Each agent request can make several model calls, so check model capacity and rate limits alongside agent instances, and use traces to see where the time goes.
Do I need sticky sessions?
Only if a session keeps state in memory on one instance. Send the session ID in the X-Routing-Key header and persist anything important, because sessions can move during deployments, crashes or rebalancing.
Should high-throughput agents run on Model Serving?
For new agents, Databricks recommends Agent Runtime on Databricks Apps, and agents deployed to Model Serving endpoints are now a legacy option. Model Serving still matters for the custom models and tools an agent calls.
How do I absorb traffic spikes?
Accept long requests as background invocations and poll for results, keep minimum model capacity high enough for baseline traffic plus typical bursts, and retry 429 responses with exponential backoff.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.