How many LiteLLM workers per pod should you run?
LiteLLM recommends running one Uvicorn worker per pod on Kubernetes and scaling horizontally by adding pods, so the default answer for a platform team sizing a self-hosted gateway is one worker per container and more replicas as traffic grows. Running more than one worker inside a container is a choice with side effects, and it should be made deliberately rather than inherited from a template. A worker, in this context, is an operating system process that runs its own copy of the LiteLLM proxy application and handles requests in parallel with its siblings. Each worker holds its own memory, its own connection pools and its own in-process state, which is why the count matters for capacity, cost and failure behavior.
Most teams need this topic in one of two situations: they have already set pod resources and find that one worker leaves CPU idle, or they are tuning an existing deployment where memory climbs over days of sustained traffic. Before changing anything, confirm the current request profile, pod resource requests and limits, and the database connection budget, because each of those moves when the worker count moves. The sibling topics on autoscaling LiteLLM and load testing set the traffic targets that this decision must meet. Read those first so that the worker count is chosen against measured demand, not a guess about peak load.
The practical question is whether a second pod or a second worker is the cheaper way to add capacity. Pods can be scheduled, drained and autoscaled by Kubernetes, while workers share the container's CPU and memory limits and fail together with it. Add workers only when the container's own resources are underused and the platform cannot reasonably scale out. Confirm with LiteLLM's current guidance for your release, since the server tuning documentation describes Gunicorn as a supervisor for several workers in one container, and check that your resource requests still match the workers you plan to run.
Worker layout options and when each fits
This table compares three ways to lay out LiteLLM worker processes inside a container, plus the worker recycling flag that bounds memory growth. Read each row against your pod sizing and database connection budget, then confirm worker counts and flag behavior against the server tuning documentation before you set them.
| Layout | Typical situation | Memory and database connections | Main risk |
|---|---|---|---|
| Uvicorn directly, one worker per pod | Kubernetes deployments that scale out with more pods, which LiteLLM recommends as the default | One process holds one pool of database connections, so connection count grows only with pod count | Capacity depends entirely on the autoscaler adding pods quickly enough |
| Multiple Uvicorn workers in one container | Several workers must share a single container, for example on a VM or a container with a fixed resource limit | Each worker opens its own connection pool and loads its own copy of the application, so both multiply per container | Connection and memory use can exceed database limits or the container memory limit before CPU is saturated |
| Gunicorn supervising Uvicorn workers via --run_gunicorn | Several workers per container where you want a process manager to restart failed workers | Same multiplication as multiple Uvicorn workers, plus a supervisor process; confirm the exact footprint in your own environment | Supervisor and worker settings interact, so a misconfiguration can hide crashes or restart workers too often |
| --max_requests_before_restart | Any layout under sustained load where worker memory grows over time | Recycling briefly drops a worker's in-memory state and connections while its replacement starts | Set too low, recycling causes repeated restarts and latency spikes; confirm the value against the server tuning docs |
Setting worker count and recycling in a LiteLLM deployment
This sequence moves a LiteLLM gateway from a one-worker baseline to a measured worker count with bounded memory, and confirms each change with process, memory and connection checks before it reaches production.
Start with one Uvicorn worker per pod
Deploy the LiteLLM proxy with a single Uvicorn worker in each pod and scale out with replicas rather than adding workers inside the container. LiteLLM recommends this layout on Kubernetes, so it is the reference point for every later change. Your platform or deployment team sets the container command and resource requests in the chart or manifest. Done means the pod runs exactly one gateway process, confirmed by listing processes inside the container and checking that the process count matches the configured worker count.
Load test to measure per-worker behavior
Run a load test against a fake model endpoint so provider limits do not distort results, using traffic that matches your prompt sizes and streaming mix. Record memory use, p95 latency and the number of requests in flight for the single worker as load rises. Your performance or platform engineers own the test and the findings. Done means you have a memory and latency curve for one worker, which tells you whether one worker has headroom or whether extra capacity should come from more pods or more workers.
Decide whether Gunicorn or a second worker is needed
Add a second worker only when several workers must share one container and scaling out with pods is not practical. LiteLLM suggests --run_gunicorn in that case, because Gunicorn supervises the Uvicorn workers. Each extra worker adds its own connection pool and its own rate-limit counters when no shared Redis is present, so the decision must be made with those multipliers in view. Done means a written choice of worker count and process manager, with the reason tied to the load test results.
Set max requests before restart
Set --max_requests_before_restart so each worker is recycled after a fixed number of requests, which bounds memory growth under sustained load. Choose the value from the memory trend in your load test, not from a guess, and confirm the setting is passed to the process that actually runs. Your platform team owns the start command, and the security or operations team should agree that recycling is acceptable for in-flight streaming requests. Done means the running command shows the flag and a restart is observed in logs after the configured request count.
Count PostgreSQL connections against the pool
Multiply the number of pods by the number of workers per pod and by the connection pool size each worker opens, then compare the result with the connection limit on your PostgreSQL instance and any pooler in front of it. Recycled workers reconnect, so confirm that the total stays steady during restarts. Your database team should check active connections while the load test runs. Done means the observed open connections match the expected figure within a small margin, and headroom remains for administrative sessions and failover.
Verify health checks and memory trends
Configure liveness and readiness probes against the gateway health endpoint and keep them separate from long-running requests so a recycling worker does not cause a restart loop. Run a sustained load test for a period your team sets, plotting memory per worker across recycle events. Operations owns the dashboards and alerts. Done means memory returns to a stable band after each recycle, no probe failures occur during normal recycling, and the alert thresholds are recorded with the worker settings.
Record settings and recheck after upgrades
Write the final worker count, process manager, recycle value, pool size and expected connection total into your configuration as code, so the values are reviewed with every change. Repeat the process count and connection checks after each LiteLLM upgrade, because the default server behavior and the memory profile can change between releases. Your platform team keeps the record and the upgrade checklist. Done means the settings live in version control and the post-upgrade checks are part of the release runbook.
How worker count multiplies database connections and rate limits without Redis
Every LiteLLM worker is a separate process with its own memory, its own database connection pool and its own in-memory state. That means the load on PostgreSQL and the effective rate limits both scale with worker count multiplied by pod count. A pod running four workers with a pool of 10 connections each can hold up to 40 connections to the database, and three such pods hold up to 120. Before you pick a worker count, confirm the pool size and connection limits the current release uses in the LiteLLM docs: production best practices, then check that your PostgreSQL max_connections and any pooler limits leave room for that total across all pods, plus headroom for rolling upgrades when old and new pods overlap.
The same multiplication applies to TPM and RPM limits on virtual keys. Without a shared Redis, each worker counts requests in its own memory, so a key with an RPM limit of 60 can, in aggregate, send more than 60 requests per minute if several workers or pods each admit traffic against their local counters. The production guide requires Redis 7.0 or newer once more than one proxy instance runs, precisely for shared rate limits, router state and cache. Treat that as a hard prerequisite for a multi-pod or multi-worker gateway, not an optimization. Confirm the exact Redis settings and which counters move to Redis in your release before you rely on a limit for cost control or fair sharing.
For planning, a single-worker pod with a single Redis-backed counter set is the simplest model to reason about, and it is what LiteLLM recommends on Kubernetes when you scale horizontally. If you run several workers in one container, write down the effective connection count and the effective limit per key before go-live, then test both with a deliberate burst from several clients to confirm that limits hold and that PostgreSQL does not refuse connections. Ask your implementation partner or internal platform team to document these numbers next to the worker setting so that any future change to workers, pods or pool size is checked against them.
Security and operational risks of worker tuning
Worker count, recycling and process supervision change more than throughput. Each setting also changes where secrets appear, how streaming requests end, how rate limits are counted, how many database connections open and how you see failures. The cards below cover the risks to review before you change a worker setting in production.
Keep the master key out of arguments
The LITELLM_MASTER_KEY must start with sk- and grants full administrative access to the gateway. Passing it as a command-line argument can expose it in process listings, container inspection output and startup logs, and Gunicorn wrappers often echo their command line when a worker fails. Load the key from a secret manager into the environment at runtime, and confirm that your startup scripts and logging configuration never print it. Check this again whenever you change the launch command.
Worker recycling can cut streams
When --max_requests_before_restart recycles a worker, requests already running on that worker can be interrupted if the process exits before the response finishes. Long streaming completions are the most exposed. Set the recycle threshold high enough that recycling is rare under normal load, and confirm with your team how the gateway behaves for clients that retry on a dropped connection. Test a recycle during a streaming load test before you rely on it.
Rate limits multiply without Redis
Virtual key TPM and RPM limits count traffic in each worker process. Without a shared store such as Redis, a key with a 60 RPM limit running on four workers can be served far above that limit, because each worker counts its own requests. Budget enforcement and router state have the same problem. Before raising worker count, decide whether you need Redis 7.0 or newer for shared state and test a key limit across several workers to confirm the result.
Connection counts grow with workers
Each worker process opens its own connection pool to PostgreSQL, so the total connection count grows with the number of pods multiplied by the number of workers per pod. A layout that looks modest on paper can exhaust the database max_connections limit during a traffic spike, and the failures then appear as errors across unrelated requests. Calculate the total before you change worker count, check the database's connection ceiling, and plan connection pooling in front of PostgreSQL.
Supervised workers hide failures
When Gunicorn supervises several Uvicorn workers, a crashed or recycled worker can be replaced silently, so the pod looks healthy while requests fail or slow down. Restart counts, per-worker memory and in-flight requests may not reach your dashboards unless you collect them. Decide which signals you need, such as restarts, memory per process and request latency per pod, and confirm that your logging and metrics setup captures them before go-live.
Track runtime flag changes
Worker flags such as the Gunicorn switch, worker count and recycle threshold change how the gateway behaves, and their names and defaults can change between releases. Keep each setting in version-controlled configuration, record which release it was tested on, and review it when you move to a new minor version. LiteLLM maintains support for the four most recent stable minor versions, so plan upgrades on that cycle and retest worker settings after each one.
- Supported minor versions
- 4
Questions buyers ask about LiteLLM worker tuning
How much tuning effort does LiteLLM worker count actually take?
Most of the effort is measurement, not configuration. Setting the worker count is a small change, but deciding on it means running a load test against a realistic traffic mix, watching memory, latency and database connections at each worker count, and repeating the run after any change to the gateway configuration. The LiteLLM production guide recommends one Uvicorn worker per pod on Kubernetes and horizontal scaling, so for many teams the effort is confirming that default holds for their workload. Where several workers must share a container, the effort rises because memory per worker, recycling thresholds and connection pool sizes all need to be set together and checked again.
Can our own platform team tune workers without outside help?
Yes, if the team already runs Kubernetes workloads, can operate PostgreSQL connection limits and can run a load test with a fake provider endpoint. The hard parts are reading memory growth over a sustained run, separating gateway overhead from provider latency, and knowing which database connections multiply with each worker. Teams without a load testing habit usually find the first full cycle takes the longest. An outside partner can take the test design, run it and write up the settings, but the decisions about acceptable latency and cost per pod stay with your organization.
What do we need to provide for a worker tuning exercise?
You need a non-production environment that matches the production container image, resource requests and network path to your model providers or a fake OpenAI-compatible endpoint standing in for them. Database access is required so the team can read PostgreSQL connection counts and settings during each run. Confirm whether you run more than one proxy instance, because the LiteLLM production guide requires Redis 7.0 or newer once that happens, for shared rate limits, router state and cache. Also provide the expected request mix, prompt sizes and streaming share, and access to your metrics stack so memory and latency can be recorded for each configuration.
How long does validating a worker configuration take?
The duration depends on how many worker counts you test, how long each sustained run must last to show memory growth, and how quickly your environment can be reset between runs. Each additional configuration adds a full run plus analysis, and a recycling setting such as the one for max requests before restart only shows its effect under sustained load, so short tests will not reveal it. Ask any partner to state the number of configurations, run lengths and environment changes that its quote assumes, and to list which of those you must supply. No fixed duration is set here.
What drives the cost of this work up or down?
Cost follows the number of pods, the number of configurations to compare, how closely the test environment matches production and how many people must review the results. A simple one-worker-per-pod setup on Kubernetes with an existing load test harness costs less to confirm than a container that runs several Gunicorn-supervised workers against a shared PostgreSQL pool with a recycling policy. Recurring costs appear when traffic patterns change, a new model provider is added or LiteLLM is upgraded, because the same measurements must be repeated. Ask for a quote that lists one-time test work separately from any retainer for re-testing.
Do we need Gunicorn to run LiteLLM on Kubernetes?
Usually no. LiteLLM runs on Uvicorn by default, and its server tuning guidance says to use the --run_gunicorn option only when several workers must share one container. On Kubernetes the recommended pattern is one Uvicorn worker per pod with horizontal scaling, which keeps each pod's memory, connection count and failure domain small. Gunicorn becomes worth testing when your platform cannot schedule enough pods, or when you need several workers in one container for a specific reason. In that case, check that each worker's connections and memory are counted against PostgreSQL and any rate limits that are not shared through Redis.
How does worker count change database connections and rate limits?
Each worker keeps its own database connection pool, so total PostgreSQL connections grow with pods multiplied by workers per pod. Without Redis, per-process state such as in-memory rate limit counters is not shared across workers or pods, so a TPM or RPM limit can be exceeded in aggregate. Confirm the connection ceiling on your PostgreSQL instance, the pool size LiteLLM opens per worker and whether a connection pooler sits in front of the database. Redis 7.0 or newer is required once more than one proxy instance runs, so plan for it before raising workers or pods.
How pods, workers and shared state connect
Traffic enters through a load balancer and reaches one of several LiteLLM pods. Inside each pod, Uvicorn workers handle requests, optionally supervised by Gunicorn when several workers share one container. Every worker holds its own PostgreSQL connection pool, so the total connection count grows with pods multiplied by workers. When more than one instance runs, a shared Redis holds rate-limit and router state. Check the pool size per worker and the Redis path before you raise the worker count.
Requests flow through pods, and each worker opens its own database pool.
How DeployOpen scopes and delivers LiteLLM worker tuning
DeployOpen treats LiteLLM worker tuning as a measured change to a self-hosted gateway, not a single setting. We agree the worker layout, database connection budget and recycling policy in writing, test them against your traffic pattern, and hand over the configuration with the reasoning behind each value so your team can run it.
How we scope
- Inventory the current proxy image, worker flags, pod resource requests and the PostgreSQL connection limit before any change is proposed.
- Confirm whether each pod runs one Uvicorn worker or several, and whether Redis is in place once more than one proxy instance runs.
- Agree in writing which worker counts, recycling thresholds and load tests are in scope, with the fixed-scope deliverables listed.
How we build
- Set worker counts and recycling limits in your deployment manifests, not by editing running containers, so changes stay reviewable.
- Calculate the database connection and rate limit budget that your chosen worker count multiplies, and check it against pool settings.
- Run sustained load tests against the tuned layout and record memory growth per worker to confirm the recycling interval is sensible.
How we hand over
- Deliver the configuration as code with a short record of each value, the test that justified it and the conditions that would change it.
- Document the worker count, recycling setting and connection math so platform and security teams can review them independently.
- Walk your operations team through the dashboards and log lines that show worker restarts, memory trends and connection pressure.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer, so tuning is revisited when the LiteLLM release line changes.
- Re-run load tests after traffic shifts, new models or changes to pod resources, and update the documented values to match.
- Confirm with LiteLLM's current release notes and server tuning guidance before each upgrade, since flags and defaults can change between versions.

