What Breaks When a Self-Hosted LLM Gateway Hits 1,000 Concurrent Streams
The AI briefing for Developers
Stay up to date with AI tools, model releases, and developer workflows that matter.
Weekly. Free. One click to leave.

- Premium Results
- Publish articles on SitePoint
- Daily curated jobs
- Learning Paths
- Discounts to dev tools
7 Day Free Trial. Cancel Anytime.
We sent 1,000 streaming calls at the same moment through three self-hosted LLM gateways: the Langfuse AI Gateway, the LiteLLM proxy and AcruxCore. Each gateway was limited to 2 CPUs. As shipped, Langfuse finished 261 of the 1,000 streams and LiteLLM finished 403. Neither failure came from the gateway's own code.
Langfuse's failures came from Linux's open-file limit, which Docker sets to 1,024 by default. LiteLLM had that problem too, plus a second one: an empty key cache sent hundreds of database lookups at once, and the ones that waited longer than 10 seconds were rejected. This article shows how each failure looked, how we traced it to its cause, and the settings that fixed it.
The Test Setup
This benchmark measured the resource consumption of three LLM gateways under scaling concurrent streaming loads.
- Hardware: AMD Ryzen 9 5900X (62 GB RAM) with gateway Docker containers capped at 2 CPUs; supporting architecture was unrestricted.
- Software: Langfuse 4.77.0, LiteLLM 1.108.4 (using Postgres for production-style key checks), and AcruxCore 2026.11.4.
- Workload: A Node.js script sent concurrent streams to OpenAI
gpt-6-luna(asking to count to 60) in batches of 10, 100, 250, 500, and 1,000. - Execution: Batches ran sequentially, waiting for all streams to finish followed by a 15-second pause between levels.
- Metrics: Container CPU and memory were sampled every 250 ms directly from the kernel's cgroups during the November 10, 2026 test.
Full latency, memory, and feature results are available in the Langfuse vs LiteLLM vs AcruxCore benchmark.
The Symptoms
| Concurrent streams | Langfuse | LiteLLM | AcruxCore |
|---|---|---|---|
| 250 | 250 ok, first token 1.4 s | 250 ok, first token 9.8 s | 250 ok, first token 1.5 s |
| 500 | 110 ok, 390 × 502 | 249 ok, 251 × 503 | 500 ok, first token 2.2 s |
| 1,000 | 261 ok, 739 × 502 | 403 ok, 597 failed | 1,000 ok, first token 3.5 s |
First-token times are medians of the streams that succeeded. Up to 250 streams, every gateway succeeded. Then the errors started, and they did not look alike:
- Langfuse returned
502 Upstream request failed. A second run gave the same result, with 125 of 500 streams succeeding. - LiteLLM at 500 returned
503 Service Unavailable, the authentication database is temporarily unreachable. - LiteLLM at 1,000 returned 390 ×
500 OpenAIException - Connection error, and 207 calls lost their connection without any response.
A 502 and a 503 point at different layers, so we expected two different causes. Two of the three turned out to share one cause.
Cause One: 1,024 Open Files
Linux counts every network connection as an open file, and it caps how many open files one process may hold. The cap has two values. The soft limit is the cap that is in force now. The hard limit is the ceiling: a process may raise its own soft limit up to that value, and no further.
A streaming gateway holds two connections for each stream: one from the client, and one to the model provider. That makes about 1,000 open files at 500 streams, and about 2,000 at 1,000 streams. A gateway also needs a few more files for its database, its logs and its own libraries.

Docker on our machine gave every container a soft limit of 1,024 and a hard limit of 524,288. All three gateways received the same two numbers. What differed was how each program treats them when it starts:
| Gateway process | Language | Open-file soft limit while running |
|---|---|---|
Langfuse ai-gateway | Rust | 1,024 |
| LiteLLM | Python | 1,024 |
| AcruxCore API | Node.js | 524,288 |
Node.js raises its own soft limit to the hard limit at startup. The Rust and Python services keep 1,024, and neither project's Compose file sets a higher value. So the two gateways ran out of open files near 500 streams, which is the point where the errors started.
The out-of-files error appeared as a failed connection, not as a clear message. The Langfuse gateway's logs showed failed connections to OpenAI, and also failed connections to Langfuse's own web service, which the gateway asks to check each key. Both come from one cause: a process that cannot open another file cannot open another socket. Its client then receives a 502.
How to Check a Running Container
Read the limit the process actually has, not the one you think Docker gave it. Process 1 is usually the main process in a container:
docker exec <container> sh -c 'grep "open files" /proc/1/limits'
If the gateway runs under a supervisor or several workers, check each worker's process ID instead of process 1. To see how close a process is to its limit under load, count its open file descriptors:
docker exec <container> sh -c 'ls /proc/1/fd | wc -l'
The Fix
Raise the limit for the gateway service in its Compose file. We used 65,536 for all three gateways:
services:
langfuse-ai-gateway:
ulimits:
nofile: { soft: 65536, hard: 65536 }
The same ulimits block works on the LiteLLM service. On Kubernetes or another platform, check /proc/<pid>/limits inside a running container rather than assuming a value.
Cause Two: LiteLLM's Cold Key Cache
With the open-file limit raised, the Langfuse gateway finished all 1,000 streams. LiteLLM still returned 503 errors. To separate the two causes, we ran LiteLLM with one worker and only the open-file limit raised. All 500 streams succeeded in that ladder, but 595 of 1,000 failed with 503.
The 503 message names the authentication database, so we read LiteLLM's logs and its source. The log gave the same reason for all 840 failed streams in these runs, 595 in that ladder and 245 in the cold-cache runs below:
key lookup did not answer within 10s
Three settings in LiteLLM explain it:
- A 60-second key cache. LiteLLM checks each virtual key in Postgres and keeps the result in memory for 60 seconds (
in_memory_cache_ttlinproxy/proxy_server.py). - A small database pool. Each LiteLLM worker opens at most 10 connections to Postgres.
- A 10-second deadline. A key lookup that takes longer than
PROXY_DB_LOOKUP_DEADLINE_SECONDS, 10 seconds by default, is cancelled. LiteLLM then rejects the call with503(proxy/db/db_lookup_gate.py).
When 500 calls arrive while the key is not in the cache, each call looks the key up in Postgres. All of those lookups queue for 10 connections. The worker was also using its whole CPU allowance at this point, which slows every query it sends and receives. We infer that this CPU load lengthens the queue, but we did not measure it separately. Whatever the share of each, the lookups at the back of the queue miss the 10-second deadline.

If that explanation is right, the failures should depend on whether the key is already in the cache. So we ran 500 streams four more times. Three runs started after 75 seconds with no calls, which is longer than the 60-second cache. One run started right after a single warm-up call:
| Run | 500 streams |
|---|---|
| Key not in cache, run 1 | 339 ok, 161 × 503 |
| Key not in cache, run 2 | 416 ok, 84 × 503 |
| Key not in cache, run 3 | 500 ok |
| One call first, so the key is in the cache | 500 ok |
The warm run had no failures. The cold runs failed by different amounts, 161, 84 and 0, because the result depends on how many lookups miss the deadline, and that changes from run to run. This probably explains why the earlier ladder succeeded at 500 and failed at 1,000. A run is a race between the lookup queue and the deadline, so a single ladder does not show where the limit is.
What You Can Do About It
The warm-up result is the one we measured. Send one call with each virtual key after LiteLLM starts, and avoid quiet periods longer than 60 seconds before a traffic spike. A steady flow of traffic keeps the key in the cache.
LiteLLM also exposes three settings that act on this path. We did not test them, so treat them as places to look rather than proven fixes:
general_settings.user_api_key_cache_ttlchanges how long a key stays in the in-memory cache.- The
PROXY_DB_LOOKUP_DEADLINE_SECONDSenvironment variable changes the 10-second deadline. - The
PROXY_DB_LOOKUP_MAX_CONCURRENCYenvironment variable, 25 by default, caps how many lookups run at once in each worker.
After Both Fixes
We raised the open-file limit to 65,536 for all three gateways and gave LiteLLM 2 workers, one per CPU, as its production guide recommends for a single machine. Then we ran the full ladder again:
| Concurrent streams | Langfuse | LiteLLM | AcruxCore |
|---|---|---|---|
| 250 | 250 ok, first token 1.2 s | 250 ok, first token 4.7 s | 250 ok, first token 1.5 s |
| 500 | 500 ok, first token 1.4 s | 380 ok, 120 × 503 | 500 ok, first token 2.2 s |
| 1,000 | 1,000 ok, first token 1.7 s | 1,000 ok, first token 19.2 s | 1,000 ok, first token 3.8 s |
The open-file errors were gone for every gateway, and the Langfuse gateway gave the fastest first token of the three. LiteLLM still returned 120 × 503 at 500. That level started about 60 seconds after the first call of the ladder, so the cached key had probably just expired. All 1,000 succeeded at the next level, which started within 60 seconds of the 500 level.
The Limit That Remains Is CPU
Once nothing failed, CPU decided the first-token times. LiteLLM used its whole 2-CPU allowance from 100 streams on, and its median first token took 19.2 seconds at 1,000 streams. AcruxCore also used both CPUs from 100 streams on, and its first token at 1,000 streams was 3.8 s at the median and 9.7 s at p95. The Langfuse gateway peaked at 1.65 CPUs and 168 MiB, with a first token of 1.7 s at the median and 9.6 s at p95.
Each gateway also needs the rest of its stack, and that stack uses CPU too. While the Langfuse gateway served 500 streams, its whole stack used up to 3.1 CPUs, because the web service checked keys and the worker and ClickHouse stored usage. AcruxCore's whole stack peaked at 4.0 CPUs, because its API writes a trace for every call to Postgres. Size the stack around the gateway, not only the gateway container.
A Checklist Before You Load-Test a Gateway
- **Read the open-file limit from **
/proc/<pid>/limitsinside each gateway process, including every worker. Raise it before the test, not after the first failure. - Count connections per request. A streaming proxy holds at least two, so the limit must be more than twice your target concurrency.
- Run each level more than once when a failure depends on a cache or a queue. One clean run does not show the limit.
- Test with the cache cold and warm. The first burst after a quiet period is often the hardest one.
- Read CPU from the cgroup during the test. A first-token time that rises with load, with no errors, usually means the CPU allowance is full.
- Match each failure to a log line. We counted 840 failed streams and 840 matching log lines before we trusted the explanation.
Talha Anwar is a senior AI and full-stack engineer and writes about building and running AI systems at talhaanwar.com.