BlogInfrastructure
Running LiteLLM in production
A production LiteLLM gateway is at least two stateless gateway pods with one worker each, an external Postgres database, Redis, and about ten settings that are not the defaults. LiteLLM's own production checklist names them. This page puts that checklist in the order in which the decisions come up and adds the two questions it leaves to you: how many database connections you can afford, and whether the gateway should keep serving when the database is down. As of 27 November 2026.
The pieces
| Component | What it holds | What LiteLLM recommends |
|---|---|---|
| Gateway pods | Nothing. They are stateless | Two or more replicas behind a load balancer. On Kubernetes one worker per pod, and you scale by adding pods |
| Postgres | Keys, teams, budgets, spend | An external database, not one inside the gateway's chart |
| Redis | Shared counters for rate limits and budgets | Version 7.0 or newer, as soon as more than one instance runs |
| Migration job | Schema changes | Run migrations in a separate job and switch them off on the serving pods. The Helm chart does this |
For sizing LiteLLM gives a starting point of 1 vCPU and 4 GiB of memory per worker, to be adjusted after a load test. Two pods of that size carry a pilot comfortably. The gateway mostly waits for providers, so memory and connections run out before CPU does.
Settings that are not the defaults
| Setting | Value | Why |
|---|---|---|
| LITELLM_MASTER_KEY | A long random value from your secret manager | It can do everything |
| LITELLM_SALT_KEY | Set before the first model is added, then never changed | Changing it makes stored provider credentials unreadable |
| trusted_proxy_ranges | The address ranges of your load balancer | So the gateway knows which forwarded client addresses to believe |
| proxy_batch_write_at | 60 | Spend is written every 60 seconds and not on every request |
| request_timeout | 600 | The default is 6000 seconds, which keeps dead requests open far too long |
| set_verbose and LITELLM_LOG | False and ERROR | Debug output does not belong in production logs |
| LITELLM_MODE | PRODUCTION | Stops the gateway from loading a local .env file |
| The image | Pinned to a digest | A tag can be moved. A digest cannot |
Database connections add up
Every worker opens its own pool of connections to Postgres, ten by default. The total is instances times workers times pool size. LiteLLM's example: three instances with four workers each and a pool of ten open 120 connections. On Kubernetes with one worker per pod, an autoscaler that goes up to ten pods can open 100.
Check that number against what your database allows before you switch autoscaling on. A small managed Postgres often allows fewer connections than a scaled-out gateway asks for, and the failure shows up under load, which is the worst moment. Set database_connection_pool_limit so that the largest number of pods still fits.
At very high volume, which LiteLLM puts at roughly 1000 requests a second or more than ten instances, it recommends buffering spend writes through Redis with use_redis_transaction_buffer. Most companies are far from that.
When the database is down
LiteLLM leaves this decision to you. The readiness endpoint answers with status 200 even when the database is unreachable, so the pods stay in service. What they do with requests depends on one setting.
- Without allow_requests_on_db_unavailable, keys that are still in the gateway's cache keep working for about a minute. After that, requests with virtual keys fail.
- With it, the gateway lets requests through while it cannot check keys against the database. LiteLLM says to use this only when the gateway is not reachable from the public internet.
- In both cases, creating keys and teams fails, and you should not rely on spend and budgets being exact for that period.
The question behind the setting is whether an hour without budget enforcement is worse for you than an hour without AI. For internal developer tools we would keep serving. Where a budget is a hard control, we would not.
Scaling
Do not scale on CPU alone. Requests spend most of their time waiting for a provider, so CPU stays low while users already queue. LiteLLM recommends scaling on requests and tokens per second as well, and keeping spare replicas for long streamed answers. Keep the default routing strategy unless you have a reason, because usage-based routing adds a Redis lookup to every request.
We deploy this setup from Helm and Terraform in the client's repositories, and then keep it up to date or hand it to their platform team.
Questions
How many replicas does LiteLLM need in production?
At least two behind a load balancer. On Kubernetes LiteLLM recommends one worker per pod and scaling by adding pods.
Does LiteLLM need Redis?
A single instance works without it. With more than one instance you need Redis 7.0 or newer, otherwise each instance counts rate limits and budgets on its own.
What happens to LiteLLM when Postgres is down?
The pods stay up. Cached keys keep working for about a minute. Whether requests are served after that depends on the setting allow_requests_on_db_unavailable. Key management fails until the database is back.
Related services
LiteLLM gateway
Budgets and access rules for every team's AI use, through a LiteLLM gateway that is hardened, connected to your identity provider and kept up to date.
AI platform for all teams
One approved route to AI for every team, with budgets, logs and a free choice of model, run on your servers or in your cloud.
More from the blog
Where to host LiteLLM
Three ways to host a LiteLLM gateway: your own cloud account, a hosting provider in Germany, or a partner who runs it and hands it over. What each costs you in control, and how to move it in-house later.
LiteLLM in production
How to keep running a self-hosted LiteLLM gateway after the March and October 2026 release compromises and two exploited vulnerabilities, from checking whether you were hit to the settings and checklist we use before go-live.
LiteLLM logging and privacy
Where a LiteLLM gateway can store prompts and answers, which settings keep content out of logs, who is allowed to override them, and what to settle before the first team connects.
Introducing an AI gateway
Introducing an AI gateway is a migration: find where models are called today, move applications and people over one by one, close the old paths, and make the gateway the easier way to get a model.
Talk to an engineer
Bring one piece of work you would like to improve. The call takes 30 minutes and needs no access to your systems or your data.
Booking runs on Google Calendar.

Mickey Graf
Founder and CEO of Cloudsail
Prefer to write first? Leave your email and a few lines. Mickey reads every message himself and replies by email with times for a call.
Look for the draft in your email program
Send it from there, and Mickey replies in person with times for a 30-minute call. If no draft has opened, write to us at miki@cloudsail.com.