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.

By Updated

The pieces

Components of a production LiteLLM deployment, from LiteLLM's deployment and production documentation, checked on 27 November 2026
ComponentWhat it holdsWhat LiteLLM recommends
Gateway podsNothing. They are statelessTwo or more replicas behind a load balancer. On Kubernetes one worker per pod, and you scale by adding pods
PostgresKeys, teams, budgets, spendAn external database, not one inside the gateway's chart
RedisShared counters for rate limits and budgetsVersion 7.0 or newer, as soon as more than one instance runs
Migration jobSchema changesRun 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

Production settings from LiteLLM's production best practices, page last updated on 10 October 2026
SettingValueWhy
LITELLM_MASTER_KEYA long random value from your secret managerIt can do everything
LITELLM_SALT_KEYSet before the first model is added, then never changedChanging it makes stored provider credentials unreadable
trusted_proxy_rangesThe address ranges of your load balancerSo the gateway knows which forwarded client addresses to believe
proxy_batch_write_at60Spend is written every 60 seconds and not on every request
request_timeout600The default is 6000 seconds, which keeps dead requests open far too long
set_verbose and LITELLM_LOGFalse and ERRORDebug output does not belong in production logs
LITELLM_MODEPRODUCTIONStops the gateway from loading a local .env file
The imagePinned to a digestA 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.

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

Mickey Graf

Founder and CEO of Cloudsail

Rated 4.9 out of 5 on Clutch

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.

The button prepares an email in your own email program, for you to send. Privacy policy (draft)