Finding · affects your cloud bill
Requests held open on LLM calls
A request that waits on a model holds a connection for seconds; when the provider slows down, those held connections multiply until other requests can't get in.
Why it matters
A normal API request finishes in milliseconds. A model call takes seconds, and while it runs the request holds memory and a connection on your server. At peak traffic that adds up to a number of simultaneously open requests, and your servers have to be sized for it.
The risk is the provider's bad day. If responses go from 5 seconds to 50, ten times as many requests are held at once, and without a concurrency limit the service runs out of room for every other route, including the ones that make money.
What it looks like
Fine at low traffic, fragile at high traffic with no limit or timeout:
const res = await client.chat.completions.create({ model, messages });
// no timeout, no concurrency limit around itHow to fix it
const res = await limit(() => // e.g. p-limit, sized per instance
client.chat.completions.create(
{ model, messages, max_tokens: 800 },
{ timeout: 30_000 }, // fail fast instead of piling up
),
);- Set a timeout on every model call.
- Cap concurrent model calls per instance, so a slow provider can't consume the whole service.
- Queue generations nobody is watching (summaries, reports, embeddings) and keep streaming only for live chat.
A real example: Vercel AI Chatbot
Computed by Skeram’s engine from the published teardown of Vercel AI Chatbot, at 10,000 monthly users (note):
1 route holds connections open on LLM calls. At 10,000 monthly users this route sees ~0.69 req/s at peak, each pinned ~3s on the LLM — on the container service shown, ~2.1 connections held open, on a $2,114–$35,344/mo token bill. If the provider slows to 30s, that becomes ~21, and without a concurrency cap the service runs out of room for every other request.
Suggested fix: Cap concurrency + set timeouts on every LLM call; queue non-interactive generations; keep streaming for chat UX.
Evidence: app/(chat)/api/chat/route.ts:70-445, lib/ratelimit.ts:22-47.
How Skeram detects it
Skeram simulates peak requests per second on each route that calls a model and multiplies by how long a call holds the connection. It reports how many requests are held at once at the slider's audience, and what happens if the provider is ten times slower.
When it starts to hurt: Grows with traffic. The finding turns critical at the audience where held connections pass a level one container can't absorb.
Every finding cites the file and line it came from, and scanning again after a fix shows it resolved in History. How the analysis works.
Questions
Isn't streaming enough?
Streaming improves how the wait feels to the user. The connection is still held for the full generation, so capacity planning is the same.
Related findings
- List and aggregate queries on hot routes: A list, search or aggregate query on your busiest route gets slower as data grows, and it's slowest exactly when traffic peaks.
Find it in your code
Skeram reads your repo, prices every model call from 100 to 100,000 users, and flags these patterns with the file and line.