When requests to a local LLM outnumber what the GPU can handle, the queue has to be designed explicitly: limit the number of concurrent sequences in the engine, choose an ordering policy, separate users fairly, and reject excess requests in time with a 429 response instead of letting them wait forever. The engine itself only handles part of that work. Priorities between teams, quotas, and overload rejection usually live at the gateway in front of it.
Prepared by AI Studio by Vladimir Lomtev on November 16, 2026 for IT teams that run their own inference server for multiple departments or products. The article is based on the vLLM documentation, the llm-d 1.0.0 release notes from October 20, 2026, and the HTTP RFC. We did not run our own benchmark; all numbers in the examples are illustrative. Check flags and metrics against the documentation for the version you are running.
Contents
- Why a queue appears even on a powerful server
- What controls the queue inside vLLM
- Service order: FCFS or priorities
- Fairness across users and teams
- When to reject: 429 response and Retry-After
- Which metrics show that the queue is growing
- Step-by-step queue tuning
- Common mistakes
- FAQ
Why a queue appears even on a powerful server
The inference engine processes requests in iterations. On each iteration, it takes part of the waiting requests, runs one model step for them, and returns one token at a time. How many requests fit into a step depends on two resources: the iteration's compute budget and the free memory for KV cache. When new requests arrive and memory is already occupied by active conversations, the new ones wait.
Waiting grows nonlinearly. As long as load stays below throughput, the queue is almost empty. When request traffic exceeds it even briefly, the tail of the queue builds up faster than it drains, and the time to first token for the last requests grows by seconds and minutes. So the question is: who will wait, for how long, and what will the request that didn't fit get.
The queue has three levels, and it's helpful not to mix them up:
- inside the engine — the vLLM or SGLang scheduler decides which sequences go into the next iteration;
- at the gateway — the proxy or router decides whether to let the request through to the engine now, queue it, or reject it;
- in the application — the client decides whether to retry the request, show the user a wait state, or send the task to background processing.
What controls the queue inside vLLM
In vLLM, the size of a single iteration is limited by two parameters. --max-num-seqs sets the maximum number of sequences in one step, --max-num-batched-tokens is the maximum number of tokens a step will process, including prefill for new requests. Descriptions of both are in the engine arguments reference.
In the vLLM optimization guide it says that in V1, chunked prefill is enabled by default when possible. The scheduler first packs all waiting decode requests into a step, then adds prefill. If a long prompt does not fit into max_num_batched_tokens, it is split into chunks. That leads to the main tuning tradeoff:
Value of max_num_batched_tokens |
What you gain | What you pay |
|---|---|---|
| Smaller, for example 2048 | Smoother inter-token latency: prefill interferes less with responses already in progress | New long requests wait longer for the first token |
| Larger, for example above 8192 | Faster first token and higher throughput | Active responses are more likely to slow down because of someone else's prefill |
The values 2048 and 8192 are taken from the documentation as reference points, not as the optimum for your hardware. The working value should be chosen by load testing on a real mix of requests.
The second mechanism is eviction. When KV cache memory runs out, vLLM V1 evicts part of the requests by default in recompute mode: their state is reset and recomputed when memory becomes available again. The documentation recommends reducing max_num_seqs or max_num_batched_tokens if evictions happen often, so fewer requests are in the step and less cache is needed. Frequent evictions mean the queue has effectively moved inside the engine and is using GPU time for repeat work.
Service order: FCFS or priorities
By default, vLLM serves requests in arrival order (fcfs). The parameter --scheduling-policy priority enables priority-based scheduling. According to the arguments reference, a smaller value means earlier processing, and when priorities are equal, arrival time decides.
Priority is passed in the request itself. In the OpenAI-compatible server documentation for chat completions and completions there is an additional parameter priority with a default value of 0. Any nonzero value will cause an error if the model is running without priority scheduling. The same section shows the X-Vllm-Priority header, which overrides the value in the request body.
vllm serve Qwen/Qwen3-8B \
--host 127.0.0.1 --port 8000 \
--api-key "$VLLM_API_KEY" \
--scheduling-policy priority \
--max-num-seqs 64 \
--max-num-batched-tokens 4096
The numbers 64 and 4096 here are a starting point for experimentation, not a recommendation. An interactive chat client can pass priority through a header:
import os
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key=os.environ["VLLM_API_KEY"])
def ask(question: str, interactive: bool) -> str:
# In vLLM, the smaller value is served first: chat gets -10, background tasks get 10.
priority = "-10" if interactive else "10"
reply = client.chat.completions.create(
model="Qwen/Qwen3-8B",
messages=[{"role": "user", "content": question}],
max_tokens=400,
extra_headers={"X-Vllm-Priority": priority},
)
return reply.choices[0].message.content
Priority inside the engine does not create new capacity. It only changes who will wait. If there is more high-priority traffic than the server can handle, low priority may never get serviced at all. That's why priority needs protection at the entry point.
Fairness across users and teams
Priority splits traffic by importance; fairness splits it by owner. Without it, one department that starts batch processing a thousand documents will take over the entire queue, and everyone else will end up waiting even though they only have a few requests.
In llm-d, this task is handled by flow control. In in the llm-d v1.0.0 release dated October 20, 2026, it is named as one of the main themes: priority- and fairness-aware flow control and controlled degradation under overload, so latency-sensitive requests and agent bursts can share the server pool without starving each other. How the mechanism works is described in the Red Hat Developer article from August 27, 2026:
- each request has a flow key made up of priority and tenant ID, and each key has its own queue within a priority band;
- priority is set by the InferenceObjective resource; in llm-d, a larger number means higher priority, a missing object gives priority 0, and negative values mark traffic that can be dropped under overload;
- bands are served from highest to lowest, tenants are selected round-robin within a band, and FIFO order applies within a tenant queue;
- the saturation detector combines pressure on the queue and on replica KV-cache and decides when to hold requests back;
- queue limits and TTLs cap the number of waiting requests, their volume, and their wait time.
Pay close attention to the direction of the scale. In vLLM, priority −10 is served before 10, while in llm-d's InferenceObjective it is the other way around. If the llm-d gateway sits in front of vLLM with priority scheduling, agree on the scale in writing and verify it with a test.
If you do not need Kubernetes and llm-d, you can get fairness more simply: set a separate concurrent-request limit per API key or tenant at the gateway, such as LiteLLM, and send heavy batch jobs to a separate low-priority queue. Gateway options are covered in the article on enterprise AI access.
When to reject: 429 response and Retry-After
An infinite queue is worse than rejection. The user waits a minute, closes the tab, and the GPU still generates a response that nobody will read. It is fairer to return an error right away and tell the client when to try again.
The 429 Too Many Requests status code is defined in RFC 6585: the user has sent too many requests in a given period, and the response may include a Retry-After header. According to RFC 9110 , this header indicates how many seconds to wait or at what time to retry the request. The 503 code is usually used when the service is overloaded or unavailable as a whole, not because of a specific client.
The simplest admission gateway keeps two counters: how many requests are currently on the engine and how many are waiting. The example below shows the idea in FastAPI and httpx; it is not a production-ready gateway:
import asyncio, os
import httpx
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
UPSTREAM = "http://127.0.0.1:8000/v1/chat/completions"
IN_FLIGHT = asyncio.Semaphore(48) # how many requests we let through to the engine at once
MAX_WAITING = 32 # how many we can keep waiting
waiting = 0
app = FastAPI()
@app.post("/v1/chat/completions")
async def proxy(request: Request):
global waiting
if waiting >= MAX_WAITING:
return JSONResponse({"error": "overloaded"}, status_code=429, headers={"Retry-After": "5"})
waiting += 1
try:
await asyncio.wait_for(IN_FLIGHT.acquire(), timeout=20)
except asyncio.TimeoutError:
return JSONResponse({"error": "queue timeout"}, status_code=429, headers={"Retry-After": "10"})
finally:
waiting -= 1
try:
async with httpx.AsyncClient(timeout=120) as client:
upstream = await client.post(UPSTREAM, content=await request.body(),
headers={"Authorization": "Bearer " + os.environ["VLLM_API_KEY"],
"Content-Type": "application/json"})
return JSONResponse(upstream.json(), status_code=upstream.status_code)
finally:
IN_FLIGHT.release()
The limit of 48 should be tied to max-num-seqs for the engine and to test results, and the wait time should be tied to how long users are willing to wait in the interface. A client that receives 429 should retry with a pause from Retry-After plus some jitter, not immediately, or the retries will create a new wave.
Which metrics show that the queue is growing
vLLM exports metrics in Prometheus format. From the metric list for the queue, the important ones are:
| Metric | Type | What it shows |
|---|---|---|
vllm:num_requests_waiting |
gauge | How many requests are waiting to be processed |
vllm:num_requests_running |
gauge | How many requests are currently in the batch |
vllm:kv_cache_usage_perc |
gauge | Share of KV-cache in use |
vllm:num_preemptions |
counter | How many times the engine preempted requests |
vllm:request_queue_time_seconds |
histogram | How long a request spent waiting |
vllm:time_to_first_token_seconds |
histogram | Time to first token |
Useful Prometheus expressions:
max_over_time(vllm:num_requests_waiting[5m])
histogram_quantile(0.95, sum by (le) (rate(vllm:request_queue_time_seconds_bucket[5m])))
rate(vllm:num_preemptions_total[5m])
The name of the preemption counter in Prometheus may appear with the _totalsuffix; check it in the output of /metrics for your version. How to collect these metrics in Grafana is covered in the article on monitoring vLLM.
The read is straightforward. Lots of waiting requests and free KV-cache means you are hitting max-num-seqs or compute limits. If the cache is almost full and preemptions are rising, you are hitting memory limits, and increasing max-num-seqs will make things worse. If queue time rises only for background jobs, the priorities are working as intended.
Step-by-step queue setup
- Describe the traffic classes. For example, interactive chat, agent chains, and document batch processing. For each class, note the acceptable time to first token and what to do under overload.
- Measure the limit of a single replica. Use a load test to find the request rate at which p95 queue time starts to rise. That is working capacity, not the nameplate spec.
- Configure the engine. Choose
max-num-seqsandmax-num-batched-tokensso that preemptions are rare. Turn onpriorityif traffic classes need to overtake one another. - Set up an admission gateway. Limit concurrent requests and wait timeouts, return 429 with Retry-After, and split limits by API key or department.
- Move batch jobs out of the interactive flow. Run overnight exports and bulk labeling in a separate low-priority queue or on a separate replica.
- Check client behavior. Retries should respect Retry-After, and the UI should show the wait time or offer a delayed response.
- Repeat the overload test. Push traffic beyond capacity and make sure interactive requests stay within the target, while excess traffic gets a fast rejection.
Common mistakes
- Increase
max-num-seqsto make the queue disappear. If you're hitting memory limits, this will cause more evictions and recomputation. - Leave the queue unlimited. Requests wait longer than the client connection stays alive, and the GPU keeps serving users who have already left.
- Mix up priority scales between the engine and the gateway.
- Measure only average latency. The queue shows up in p95 and p99 wait times, while the average hides it.
- Keep retrying 429 without pausing. Clients end up creating the very spike the gateway was protecting them from.
Frequently asked questions
Does vLLM have a queue length limit? In the parameter documentation we relied on, there is no queue length limit with automatic 429 responses: the engine accepts requests and keeps them waiting. It is more reliable to enforce the limit and rejection at the gateway.
Which is better: priority in the engine or a separate replica for background jobs? Priority is simpler and does not require a second GPU, but background jobs still share KV-cache memory with interactive requests. A separate replica fully isolates them and costs extra hardware.
Do you need llm-d to get fairness across departments? No. For one or two servers, API key limits at the gateway are enough. Llm-d makes sense when there are many replicas running in Kubernetes.
Why did time to first token increase after enabling chunked prefill? If max_num_batched_tokens is small, a long prompt goes through prefill in several chunks between decode steps from other requests. This is an intentional tradeoff: responses that are already in progress flow more smoothly.
How Vladimir Lomtev's AI studio helps set up request queuing
Vladimir Lomtev's AI studio deploys LLMs on the company's servers and supports them in production. For request queuing, that means:
- defining traffic classes and latency targets for each department or product;
- running load testing and tuning engine parameters for the real request mix;
- integrating a gateway with limits, priorities, and predictable overload behavior;
- connecting queue metrics to monitoring and handing the team response rules.
The first step is to pick one real workflow, record the current wait time during peak hours, and define the threshold for acceptable performance. Discuss the project.
Bottom line: the queue must be limited and visible
A queue on an inference server is inevitable when demand is uneven. A good queue is limited by length and wait time, separates traffic by priority and owner, and rejects requests immediately when there is no room. Start by measuring the capacity of a single replica, then add limits at the gateway, and only after that add priority and fairness.



