Why load test a LiteLLM gateway with Locust before go-live
A platform team about to put a self-hosted LiteLLM gateway in front of production traffic needs capacity evidence before go-live, not after the first incident. A load test answers whether the proxy, its database and its Redis layer hold up under the request mix you expect, and it shows where the gateway starts to queue or fail. LiteLLM's load test documentation describes running Locust against the proxy, and it pairs that with a fake OpenAI endpoint so the test does not depend on a live provider. Read the LiteLLM load test docs before you design the run, because the setup steps and parameters are defined there.
The fake endpoint is the part that makes the results trustworthy. LiteLLM provides a hosted fake OpenAI endpoint and a self-hostable example endpoint, and the self-hosted version is the better choice for a capacity test because it keeps the traffic inside your network and removes provider rate limits, quota and latency variation from the measurement. If the test runs against a live provider, a slow or throttled response can look like a gateway problem, or a gateway bottleneck can hide behind provider limits. Confirm with your own environment that the fake endpoint sits close to the gateway on the network path you will use in production.
Run the test in three situations: before the first production rollout, after any change to the gateway version, database, Redis, worker count or routing configuration, and before raising the traffic forecast for a team or product. Schedule it early enough that a failed run leaves time to change settings and repeat it. The test does not replace the production guide's sizing advice or a soak test over a longer period, but it tells you whether the current deployment meets the load you planned for and gives you a baseline to compare future changes against.
Test design options and when each fits
This table compares four test targets for a LiteLLM load test: a hosted fake endpoint, a self-hosted fake endpoint, a real provider on low quota, and a mixed model route. Read each row for what the target measures, what it hides, and which go-live question it answers. The main takeaway is that a fake endpoint isolates the gateway, while only a real provider route shows how upstream limits and latency shape the result.
| Test target | What it measures | What it hides | When it fits the go-live decision |
|---|---|---|---|
| Hosted fake endpoint | Gateway overhead, routing, auth checks and database writes under concurrent Locust users, with no provider limits involved | Your network path to the provider, your own cloud egress limits and the real provider's latency and error patterns | Early capacity checks and regression runs after gateway configuration changes, when you want results that do not depend on a provider quota |
| Self-hosted fake endpoint | The same gateway measurements, plus the cost of traffic staying inside your network and through your own load balancer | Behavior of the real provider API, including streaming quirks and rate-limit responses | Go-live sign-off on your infrastructure when the gateway, database and Redis must be tested in the same network and cluster as production |
| Real provider with low quota | Actual upstream latency, streaming behavior, provider error responses and how retries and cooldowns react to them | Production-level throughput, since a low quota caps the request rate and token rate the test can reach | Checking that fallbacks, cooldowns and error handling work against a live provider before traffic depends on them |
| Mixed model route | Routing behavior across several deployments, including simple-shuffle distribution and failover between model groups | Per-model capacity limits unless each route is loaded separately, because one slow route can dominate averaged results | Validating a production routing configuration with more than one provider or deployment before enabling it for all teams |
| Prompt size and streaming mix | How gateway latency and memory change with short and long prompts, and with streamed versus non-streamed responses | Real user prompt distributions unless you replay sampled traffic or agree on size bands with the application owners | Setting capacity assumptions for the workload the business expects, not a single average request |
| Test client location | Latency added by the network between Locust workers and the gateway | Client traffic from real user locations and the load balancer behavior those clients would see | Confirming that the load generator is not the bottleneck before you read gateway numbers |
| Gateway metrics only | Request rate, error rate, in-flight requests, database connection use and worker health on the gateway side | Client-perceived latency unless Locust results are read alongside them | Deciding whether the gateway, database or Redis needs more capacity before a scaling change |
| Single-run results | A snapshot at one ramp level and one configuration | Warm-up effects, slow leaks and behavior over a sustained period | Not sufficient on its own for go-live; confirm a sustained run with the team's own duration target |
Matching Locust users, prompt sizes and streaming to real traffic
A load test only tells you something about go-live if the traffic it generates resembles what the gateway will actually serve. The cards below cover the parts of that profile: concurrency, ramp, prompt sizes, streaming mix and model routes. Build each one from your own gateway logs and key usage data, not from generic assumptions.
Concurrent Locust users
Set the number of simulated users from peak concurrent in-flight requests observed in your logs, not from total daily request volume. A user in Locust waits for each response before sending the next request, so user count maps to concurrency, and concurrency drives queueing at the gateway. Check whether your traffic is spread across teams, services or batch jobs, since each group can have a different peak. Illustrative: 200 peak in-flight requests across three services would be modeled as three user classes, not one.
LiteLLM load test docsRamp-up and steady-state phases
Split the run into a ramp-up phase, a steady-state hold at target load and a short cool-down. The ramp shows where latency starts climbing and which pods or workers saturate first, while the hold gives stable percentiles. Ramp slowly enough that you can tie each latency change to a specific user count. Record when each phase starts so you can align gateway metrics with the Locust timeline afterwards.
Prompt size distribution
Model prompt length as a distribution taken from your logs, with a sample of short chat turns, long system prompts and retrieval-heavy requests. Averages hide the tail, and the tail drives memory use and time to first token. Pay attention to attachments and large payloads, which can dominate gateway work even when token counts look modest. Ask your engineering team which applications send the largest prompts and weight the test toward them.
Streaming and non-streaming mix
Measure the share of streaming requests in your traffic and reproduce it in the test, because streaming holds connections open for the full generation and changes connection counts and worker occupancy. Compare the same load with and without streaming so the cost of each mode is visible. Confirm with application owners whether their clients stream by default, since a single SDK setting can flip the mix for a whole team.
Model routes and key mix
Include the same model groups, routing strategy and virtual keys that production will use, so that per-key limits, budgets and fallbacks are exercised. Weight requests across model routes the way production traffic is weighted, and include at least one failover path if your router uses retries or cooldowns. Confirm the routing settings with your team before the run, because a test with a different router produces numbers that do not transfer.
LiteLLM routing docsRunning the Locust test against your gateway
This sequence takes a gateway from an isolated test environment to a ramped load run, with a clean baseline confirmed before any user count is increased. The output is a repeatable test you can rerun after each configuration change.
Prepare an isolated test environment
Your platform team deploys a gateway copy that is separate from production, with its own PostgreSQL database and Redis instance. The production guide requires Redis 7.0 or newer once more than one proxy instance runs, because shared rate limits, router state and cache depend on it, so include Redis even if your first run uses a single instance. Keep the test database and the test
LITELLM_MASTER_KEY(which must start with sk-) out of shared secret stores used by real traffic. The step is done when the proxy health endpoint responds and the database and Redis connections show as healthy in the logs.Point a virtual key at the fake endpoint
Configure a model in the gateway that routes to a fake OpenAI-compatible endpoint instead of a live provider. LiteLLM provides a hosted fake-openai-endpoint for load tests and a self-hostable example endpoint, so provider rate limits and per-token costs do not distort results. Create a virtual key scoped to that model, with the same TPM and RPM limits you plan to use in production, so limit enforcement is part of the test. Confirm with a single request through the key that the response comes from the fake endpoint and that spend logging records it.
Write the Locust user behavior
Write a Locust file that sends chat completion requests through the gateway using the test virtual key. Model the mix you expect in production: prompt sizes drawn from your own traffic logs, a share of streaming requests, and a share of non-streaming requests, with realistic pauses between tasks. Keep the request payloads and headers identical to what your callers send, including any metadata or user identifiers. Run the file with a single user and confirm that every request returns a 200 response and that the gateway logs match the number of requests Locust sent.
Run a clean baseline before scaling
Run the test at a low user count and hold it long enough to see steady-state behavior, not only the first requests. Record the error rate, latency percentiles and the gateway's own overhead for this run, and save the Locust CSV output with the gateway configuration version. Investigate any errors, failed key checks or database connection warnings before continuing, because a baseline with errors will hide the cause of later failures. The step is complete when the baseline run has no errors and its numbers can be reproduced on a second run.
Ramp users in fixed stages
Increase the number of Locust users in stages, holding each stage long enough for latency and error rates to settle before moving up. Do not jump straight to the target count, because a sudden spike hides where the first bottleneck appears. Watch the gateway during each stage for rising queue depth, growing memory per worker and database connection use. Ask your platform team to confirm the stage sizes and hold times against your own capacity plan, since the right values depend on your worker layout and pod count.
Watch the gateway metrics during each stage
During every stage, track request throughput, p50 to p99 latency, error rate by status code, in-flight requests per pod, and memory and CPU per worker. Add the gateway overhead measurement so you can separate time spent inside LiteLLM from time spent waiting on the fake endpoint. Record database connection counts, since each worker multiplies connections. The stage is closed when its metrics are saved next to the stage's user count, so you can see which metric moved first when the system began to degrade.
Stop at the first clear limit and record it
Stop the ramp when error rates rise above your agreed threshold, latency climbs past your service target, or a gateway metric reaches its ceiling. Record the user count, the metric that broke first and the logs from that moment. Confirm the result with a repeat run at the last healthy stage to make sure the limit is stable and not a one-off. The output is a documented capacity figure tied to the exact configuration, which you can compare after each change to workers, pods or database settings.
Which gateway metrics to watch during the run
The first saturated component is the thing to find during a load test, and that only works if you collect several signals at the same time and read them against each other. Watch request latency at the median and at the tail (p95 and p99), the error rate by status code, and the gateway overhead that LiteLLM reports for each request. Alongside those, record CPU and memory for every worker and pod, the number of database and Redis connections in use, and any rate limit rejections or queueing behavior. Latency that climbs while the fake endpoint stays fast points at the gateway. Latency that climbs with a flat gateway overhead and low pod CPU points at a shared dependency or at queueing before the gateway.
Read the signals in a fixed order at each step of the ramp. First check whether the fake OpenAI endpoint is responding normally, since a slow upstream makes every gateway number look worse. Next check pod CPU and memory against the resource requests you set, then the count of connections to PostgreSQL and Redis against the limits your database and Redis settings allow. If one of those sits at its ceiling while the others have headroom, you have found the component to fix before the next step. Rising 429 responses or queued requests with idle CPU usually mean a configured limit is being hit, so check the rate limit and routing settings before adding pods. Capture the exact step, request rate, and prompt and streaming mix at the moment each signal first degraded so the finding can be repeated.
Confirm the metric names, labels and scrape settings in your own environment before the test, because they depend on how you have set up LiteLLM logging and observability and on your Prometheus or equivalent stack. Ask your platform team which dashboards already show per-pod CPU, connection counts and status codes, and whether they are retained long enough to compare runs. Check the LiteLLM docs: Locust load test for the test harness output you will compare against, and agree in writing who reviews the results and what threshold counts as a pass before the run starts.
Security and data handling during load tests
Load tests put real credentials and realistic prompts through the gateway, which can leave live access and personal data behind in places nobody reviews. The cards below cover the risks to plan for and the cleanup steps to finish before the test is considered done.
Keep master keys out of scripts
Locust scripts are easy to copy, commit and share, so a master key or a production virtual key placed in one becomes a standing credential. Create a dedicated test virtual key with a narrow model allowlist, a low budget and short-lived validity, and never reuse the master key for traffic generation. The master key should never appear in a Locust file. Load it at runtime from a secret manager so the script itself holds no secret.
Virtual keys docsStore test secrets in a secret manager
Test keys should live in the same secret manager your production gateway uses, with access limited to the engineers and CI runners running the test. Pass the key as an environment variable injected at run time rather than writing it to a .env file in the repository. Ask who can read the secret, how access is logged, and whether the value is rotated after the test window closes.
Use synthetic prompts, not production traffic
Replaying real user prompts from production logs puts personal data into Locust request logs, HTML reports and any CSV exports. Build prompt sets from generated text that matches the token length and streaming mix you need, and keep payload size and shape identical to production. If real prompts are unavoidable, redact them first and confirm the data handling rules that apply to the test environment.
Control what the gateway logs during the run
Gateway request logging and any debug output will record prompts and responses from the test, and that data then lands in the logging backend and its retention window. Decide before the run whether request content logging is on, and set a retention period for test logs that is shorter than production. Confirm that test traffic is tagged so it can be filtered out of spend and audit reports.
Remove test keys and budgets afterward
Virtual keys, team budgets and temporary budget increases created for the test keep working after the run unless someone removes them. Build the teardown into the test plan as a checklist: delete or disable every test key, reset any raised budget or rate limit, and remove test users and teams. Verify the cleanup by listing keys and confirming that the test key no longer authenticates.
Restrict who can reach the test endpoint
A load test endpoint exposed to the internet, or a fake OpenAI endpoint left running on a shared network, can be used by anyone who finds it and can distort results for other teams. Keep the test gateway on a private network or behind an IP allowlist, and shut down any self-hosted fake endpoint once the run ends. Ask who owns the test environment and how its exposure is reviewed before traffic starts.
How the test traffic flows from Locust to the fake endpoint
The run starts with Locust workers generating virtual users that send OpenAI-format requests to a load balancer, which spreads them across LiteLLM proxy pods. Each pod checks keys and limits against PostgreSQL and shares rate-limit and router state through Redis, then forwards the call to a fake OpenAI endpoint instead of a real provider. Check that metrics are collected at the load balancer, at each pod and at the database, so you can tell whether slowdowns come from the gateway, the data stores or queueing before it.
Request path from load generator through the gateway to the fake endpoint, with metrics points.
Questions buyers ask about load testing LiteLLM
What drives the cost of a LiteLLM load test?
The cost follows the amount of work the written scope asks for, mainly how many environments, traffic profiles and gateway configurations must be tested, and how much of the test harness must be built. The largest items are usually the time to model realistic traffic (prompt sizes, streaming share, key and model mix), building a fake OpenAI-style upstream so provider limits do not distort results, running several ramp-up rounds, and analyzing gateway metrics against PostgreSQL and Redis behavior. Costs rise when the gateway runs across several pods or regions, when the test must reproduce a multi-team key layout, or when fixes found during testing need retesting. Ask for a quote that lists each environment, each traffic profile, the retest rounds and the report format, and state whether tuning changes are in or out of scope.
How long does preparation for a LiteLLM load test take?
Preparation length depends on your environment more than on the test itself. The main variables are whether a staging gateway that mirrors production already exists, how closely its database and Redis settings match production, how many models and providers sit behind it, and how quickly your team can share real traffic characteristics such as typical prompt sizes and the share of streaming requests. Access approvals for the test machines, network paths from load generators to the gateway, and change windows for the staging environment often take longer than the Locust scripts. Ask for the preparation steps and the client dependencies in the written scope so both sides can see which items gate the start date.
What does our team need to provide for a LiteLLM load test?
Your team provides the access and the facts that make the test representative. Typically this includes a staging or pre-production LiteLLM deployment with its configuration, the database and Redis setup it will use in production, test virtual keys with the budgets and limits you plan to apply, and the model list and routing configuration. You should also supply traffic data or estimates: request rates, peak patterns, typical input and output sizes, and the streaming share. A named contact who can approve changes and read results is useful. Confirm with your platform team which metrics and logs they can export from the gateway and the database, because those determine what the final report can show.
Can our own team run a LiteLLM load test with Locust?
Yes, if your team has engineers comfortable with Python, the gateway's configuration, and reading Prometheus-style metrics and database statistics. LiteLLM's documentation describes running Locust load tests against the proxy, and its hosted fake OpenAI endpoint can be used so provider rate limits do not skew results. The skills gaps usually lie in designing a traffic model that matches real use, avoiding load generator bottlenecks, and interpreting results across the gateway, database and cache. Many teams run a first pass internally, then bring in an outside team for a formal baseline before go-live. A written scope makes clear which parts your team keeps.
Why does the upstream model need to be faked during a LiteLLM load test?
A fake upstream isolates the gateway so you measure LiteLLM's own overhead and capacity rather than the provider's rate limits, queueing or response times. Without it, a provider throttling your account can look like a gateway failure, and provider latency variation hides the gateway's contribution. LiteLLM provides a hosted fake-openai-endpoint for load tests and a self-hostable example OpenAI endpoint. A self-hosted fake is often preferred for internal networks, because results then do not depend on outside connectivity. Keep in mind that a fake upstream does not reproduce real provider behavior, so a separate, smaller test against live providers is still useful for confirming error handling.
Will a load test on the production gateway put our live traffic at risk?
It can, which is why most load tests run against a staging gateway built to match production as closely as practical. Testing live infrastructure risks throttling real users, exhausting database connections, and filling logs or spend tables with synthetic data. If production testing is required, the written plan should cap request rates, use dedicated test keys with tight budgets, define stop conditions, and schedule the run in an agreed window with someone watching the dashboards. Ask the provider to confirm how test traffic is tagged so it can be excluded from billing and reporting data later.
Which gateway metrics should we watch during a LiteLLM load test?
Watch the metrics that show where the gateway saturates: request throughput, error rates by status code, latency percentiles at the gateway rather than end to end, and in-flight requests per pod. Add CPU and memory per pod, the number of database connections in use, database query and write latency, and Redis latency if more than one proxy instance runs. Pay attention to the moment error rates or latency start climbing, and compare against the resource that saturates first. The exact metric names depend on your monitoring setup, so confirm them with your platform team before the test starts.
How DeployOpen scopes and delivers a LiteLLM load test
DeployOpen scopes a LiteLLM load test in writing before any traffic is generated. The scope names the target environment (the gateway version, the number of proxy pods, the PostgreSQL and Redis instances, and whether the test runs against the fake OpenAI endpoint or a model you have approved), the traffic profile (user counts, ramp-up shape, prompt size bands, and the streaming share), the metrics to capture, and the pass criteria the business has agreed to. Confirm the exact gateway release you run in production, since the release line you are on determines which settings and log fields the team can read. Writing these decisions down first keeps the results comparable when the test is repeated after a configuration change.
The written scope also sets out what DeployOpen delivers: the Locust test files and configuration, the environment definition needed to rerun them, a results report with gateway and database measurements alongside client-side latency, and a list of findings ranked by the risk they carry. Ask for each deliverable by name in the quote, and ask who owns the test harness afterward. Where tuning is needed, the scope should say whether DeployOpen makes the configuration changes, hands them to your platform team with a change record, or both. Fixes are followed by a retest against the same profile, and the scope should state how many retest rounds are included.
Testing is not always a one-off. Some organizations need a repeat run after each gateway upgrade, a new model route, or a change to worker counts or caching, and DeployOpen offers ongoing testing and support as retainers. A retainer makes sense when your traffic pattern changes often or when every release needs evidence before it reaches production. Ask what a retainer covers, how change requests are handled, and how results are kept for comparison. The effort for the first engagement depends mostly on how complete your environment is when work starts, so confirm access, sample prompts and a traffic baseline early.

