vLLM batching and chunked prefill: how the two batch limits shape latency and throughput
A team configuring a self-hosted vLLM server for chat or batch work needs to set two scheduler limits deliberately: max-num-seqs, which caps how many requests the engine runs concurrently, and max-num-batched-tokens, which caps how many tokens it processes in a single scheduler step. Chat traffic usually favors a lower token budget per step so that streaming users see steady token output, while batch jobs favor a larger budget and more concurrent sequences so the GPU stays full. Neither value is a fixed best setting. Both depend on the model, the GPU memory left after weights, the prompt and output lengths, and the latency targets the workload carries.
At each step, the scheduler chooses which waiting requests to admit and which running requests to advance. Running requests in the decode phase each need one token per step, while new requests need their prompt processed in the prefill phase. max-num-seqs limits how many sequences can be in the running set, and max-num-batched-tokens limits the total tokens scheduled in the step, so a long prompt can consume most of a step's budget. Chunked prefill splits long prompts across steps and schedules decode tokens first, which keeps existing conversations moving while a large prompt is being processed. Confirm the chunked prefill default and its interaction with these two limits for your vLLM version in the vLLM online serving docs before you tune.
The vLLM project is licensed under Apache-2.0 and has no paid edition, so the cost of tuning these limits sits in GPU or other accelerator capacity and in the people who benchmark and operate the server. Tuning is recurring work: a change in model, prompt mix or release can move the right values. Plan a benchmark run against your own traffic shape, record TTFT and token throughput before and after each change, and ask any implementation partner to deliver the chosen values with the benchmark evidence behind them.
Choosing values for interactive chat versus batch throughput
Interactive chat is judged by how quickly the first token appears and how steadily the rest of the answer streams. In vLLM, the two scheduler limits shape both. max-num-seqs caps how many requests run concurrently, and max-num-batched-tokens caps how many tokens the engine processes in one scheduling step. For chat, the usual direction is to keep concurrency modest and per-step work bounded, so that a long prompt arriving mid-conversation does not stall active decodes. The cost is throughput: fewer concurrent sequences means less work per GPU and more queued requests during peaks.
- Lower
max-num-seqsto protect decode latency: Fewer simultaneous sequences keep each stream's inter-token pace steadier, at the price of more waiting requests when traffic spikes. - Keep
max-num-batched-tokensmoderate: A smaller per-step token budget limits how much prefill work competes with decodes in any one step, which helps steady streaming. - Accept lower aggregate throughput: Expect fewer tokens per second per GPU than a batch-tuned server, and size capacity for peak concurrency rather than average load.
- Watch queueing before tuning further: Rising time to first token under load often means requests are waiting for a slot, not that the GPU is slow.
- Re-check after model or prompt changes: Longer system prompts or new context lengths change prefill cost and can move the right values.
Check these values against your own latency targets using a benchmark that mirrors your prompt lengths and concurrency, not a generic dataset.
Offline and batch workloads, such as bulk summarization, classification or evaluation runs, care about total tokens processed per hour and per GPU, and they tolerate long individual response times. Here the direction reverses. A larger max-num-seqs lets the scheduler keep more sequences in the decode batch, and a larger max-num-batched-tokens lets it pack more prefill work into each step. Both raise GPU utilization, but they also consume more KV cache and lengthen the wait for any single request.
- Raise
max-num-seqstoward what the KV cache holds: More concurrent sequences improve decode efficiency until cache memory runs short, at which point requests are preempted and throughput gains flatten. - Raise
max-num-batched-tokensfor prefill-heavy jobs: Long input documents benefit from larger per-step budgets because more prompt tokens are processed together. - Accept higher per-request latency: Individual jobs can take longer to start and finish, and that is acceptable only if the job owner agrees to it in writing.
- Measure preemption and KV cache use: The Prometheus metrics at /metrics expose cache usage and request behavior, which shows when a larger batch has crossed the useful point.
- Keep a separate endpoint if possible: Running batch jobs on a server that also serves chat forces one set of values to serve both goals, so a dedicated deployment often gives cleaner results.
Before settling on values, confirm with the team that owns the batch jobs what completion window they need, then run a sweep and compare tokens per second against tail latency.
Most teams do not run pure chat or pure batch, so the practical task is to decide which workload gets priority when they conflict. Start by writing down the request mix: prompt lengths, output lengths, arrival pattern and the latency each class must meet. Then choose a starting point from the vLLM documentation and recipes for your model, change one limit at a time, and measure. The values depend on the GPU, the model, the precision and the context length, so no single pair of numbers transfers between deployments.
- Separate traffic classes where possible: Two endpoints with different limits remove most of the trade-off, though they need separate capacity and monitoring.
- Change one limit at a time: Moving both at once makes it impossible to tell which change caused a latency or throughput shift.
- Benchmark with your own distribution: Use
vllm bench servewith prompt and output lengths that match production, and match concurrency tomax-num-seqsbefore drawing conclusions. - Define acceptance criteria before the sweep: Agree on the latency percentile and throughput floor each workload must meet, so the result is not judged after the fact.
- Record the values and the reason: Keep the chosen settings, the benchmark results and the release version in your configuration repository.
Confirm the starting values for your model and vLLM release in the official documentation and recipes before you benchmark, since defaults and recommendations change between releases.
Which batching options fit which workload
This table compares the five settings that govern batching and chunked prefill, plus two starting postures for interactive chat and batch throughput. Read each row as a question: what the setting limits, which workload it suits, and which default you must confirm for your release. Defaults can change between vLLM versions, so confirm them in the release you deploy before tuning.
| Setting | What it controls and when it fits | What to confirm for your release |
|---|---|---|
| max-num-seqs | Caps concurrent sequences per scheduler step. Lower suits chat with strict latency targets; higher suits batch jobs that tolerate queueing. | The default for your version, and whether your KV cache holds the sequence count you plan. |
| max-num-batched-tokens | Caps total prompt and decode tokens processed per step. Smaller budgets favor steady token streaming; larger budgets favor prefill-heavy batch work. | The default for your version, and whether it changes when chunked prefill is enabled. |
| Chunked prefill switch | Splits long prompt prefill into chunks so active decodes share each step. Fits chat traffic mixed with long prompts. | Whether it is on by default for your version and model, and which configurations force it on or off. |
| max-model-len | Sets the maximum context per request. Larger values reserve more KV cache per sequence, lowering the concurrency that fits. | The default derived from the model config in your release, and the longest prompt your application sends. |
| gpu-memory-utilization | Sets the share of GPU memory vLLM plans to use, which determines KV cache room. Raise it on dedicated GPUs; keep headroom when GPUs are shared. | The default for your release, and whether other workloads share the same GPU. |
| Interactive chat posture | Moderate sequence cap, a token budget that keeps decode steps short, chunked prefill on. Judge it by time to first token and inter-token latency. | Your own latency targets, measured with the vllm bench serve command against your real prompt mix. |
| Batch throughput posture | Higher sequence cap and token budget to fill the GPU, accepting longer per-request latency. Judge it by tokens per second at your concurrency. | Which queue waits and job deadlines your workload tolerates, confirmed by a sweep on your hardware. |
How to set and verify batching limits on a vLLM server
This sequence takes a vLLM server from a known version and model to a documented pair of batching limits, each checked under load before the next change is made.
Confirm the vLLM version and model
The platform or inference engineer records the exact vLLM release running on the server, the model checkpoint and its precision, and the GPU type and count. Batching defaults and recipe values change between releases, so the starting point must match the version in use. Check the installed version with the server's version command and compare it with the release list in the vLLM GitHub releases. Done when the version, model identifier, precision and hardware are written into the change record and nothing in the record is left to memory.
Record the starting values from docs or recipes
Look up the starting values for max-num-seqs and max-num-batched-tokens in the vLLM documentation and the model recipe that matches your model and hardware, then write them down with the source and the date you read them. Do not carry values over from a different model or GPU generation. If the recipe gives no value for your setup, record the engine default and flag the gap for the performance owner to confirm. Done when the baseline settings, their source and the launch command used to produce them are saved alongside the version record.
Set one limit at a time
Change only max-num-seqs or only max-num-batched-tokens for each test run, keeping every other flag identical. Changing both at once makes it impossible to tell which one caused a latency or throughput shift. For interactive chat, the engineer usually starts by holding the token budget steady and adjusting the sequence cap. For batch work, the reverse order is common. Restart the server with the single changed flag and confirm in the startup log that the value was applied. Done when the log shows the new value and the change record lists exactly one differing setting.
Load test with concurrency matched to max-num-seqs
Run a load test whose concurrent client count is close to the max-num-seqs value under test, using a prompt and output length mix that resembles production traffic. Use the vLLM benchmarking tooling or your own load generator, and keep the dataset and request rate identical across runs. A test at lower concurrency than the cap will not exercise the limit, so the result would not show it. Done when the run completes without client-side errors and the request count, input and output lengths, and concurrency are recorded with the results.
Read queue and KV cache metrics at /metrics
Scrape the Prometheus endpoint at /metrics during the load test and read the number of running requests, the number of waiting requests, and KV cache usage over time. A growing waiting queue while the cache is near full suggests the sequence or memory settings are limiting throughput. A cache that stays low while requests wait may point to the token budget or a scheduling limit instead. Restrict access to /metrics, because the docs do not protect it with the API key option. Done when a time series for running, waiting and cache usage is saved for the run.
Compare time to first token and inter-token latency
Using the load test client, record time to first token and per-token latency at the median and tail percentiles for each run. Interactive chat workloads are judged mainly on first-token and token-rate latency, while batch workloads are judged mainly on total tokens per second. Compare each run against the baseline and against the latency target agreed with the product owner. Done when a table shows each setting, its latency and throughput results, and whether it met the target, and the team has named the value to keep or the next value to test.
Record the verified settings and retest after changes
Write the chosen max-num-seqs and max-num-batched-tokens values into the deployment configuration, together with the vLLM version, model, hardware, load test dataset, metric snapshots and results. Repeat the sequence when the vLLM version, the model, the GPU layout or the traffic mix changes, because the best values can shift. Confirm that the deployed configuration matches the recorded values by reading the startup log after the next rollout. Done when the configuration, the evidence bundle and the retest trigger are stored where the operations team can find them.
How a scheduler step fills the batch
The step starts with two pools: waiting requests and sequences already running. The max-num-seqs cap limits how many sequences can be in the batch at once. Each running sequence contributes its decode token first, and those tokens draw down the max-num-batched-tokens budget. Whatever budget remains is filled with chunks of prompts still being prefilled, so long prompts can share the step without starving running chats. The combined batch then goes to the GPU for one forward pass. When reviewing a server, check how many decodes consume the budget and whether prefill chunks receive any tokens under peak load.
One scheduler step, from admission to the batch sent to the GPU.
Security and operational considerations for tuned batching
Raising max-num-seqs or max-num-batched-tokens changes how many requests share each GPU step, so the same flags affect latency, capacity and who can see operational data. The cards below cover the endpoints to lock down, the per-user limits that keep one caller from filling a shared batch, the metrics to watch after a change, and how flag edits are rolled out across replicas.
Allowlist endpoints at a reverse proxy
The --api-key option protects the /v1, /v2, /inference and /cohere routes, but not /metrics, /health, /pause, /resume or /abort_requests. Tuning sessions often add scrapers and operators who call these paths, so an unauthenticated /metrics can reveal queue depth and KV cache use to anyone on the network. Put a reverse proxy in front of the server and allowlist only the endpoints users need. Confirm the proxy blocks admin routes from user networks before you change batching flags.
Keep admin routes off user paths
Pausing, resuming and aborting requests are operational controls that a user-facing client should never reach. Restrict /pause, /resume and /abort_requests to an operator network or service account, and log every call. During a batching change, an operator may pause the engine to swap settings, so these routes need the same change record as the flag edit itself. Test the allowlist with a request from an ordinary client to confirm each blocked path returns a refusal.
Set per-user request limits
A high max-num-seqs lets many sequences share one batch, so a single caller sending long prompts or many parallel requests can take a disproportionate share of the token budget. Enforce per-key or per-user limits on concurrent requests and on input and output tokens at the proxy or gateway layer, sized against the concurrency you tested. Limits protect interactive users when a batch job runs alongside them, and they should be reviewed whenever the batching values change.
Watch queue and KV cache metrics
After a batching change, track request counts, token throughput, latency histograms and KV cache use from the Prometheus endpoint. Rising queue wait with flat throughput suggests max-num-seqs is limiting admission, while KV cache near capacity with preemptions suggests the batch is too large for memory. Compare time to first token and inter-token latency against the baseline for each workload class. Decide in advance which thresholds trigger a rollback, and confirm the histogram buckets cover the latency range you care about.
Roll out flag edits in controlled steps
Batching flags are set per server process, so a change applied to one replica can make replicas behave differently under the same traffic. Store max-num-seqs and max-num-batched-tokens in version-controlled deployment configuration, promote them through a staging replica, and change one replica at a time behind the load balancer. Record the previous values so rollback is a single revert. Check that replicas started from the same image and flags report the same effective settings before you widen the change.
Questions teams ask before tuning vLLM batching
Can our team tune max-num-seqs and max-num-batched-tokens without outside help?
Yes, if you have an engineer who can run a model server, read its metrics and repeat load tests. The two settings are plain vLLM serve options, and the work is mostly measurement: you change one value, replay representative traffic, and compare time to first token, per-token latency and throughput. The harder part is deciding which trade-off your users need, such as snappy interactive chat or higher batch throughput. A partner mainly adds speed and an outside view on the test design, so the decision of whether to hire help depends on how much of that skill already sits in your team.
What drives the cost of a batching tuning effort?
Cost comes from three places: GPU time for load tests, operator time, and the people who run the service afterward. vLLM itself has no license fee, so the GPU hours you spend replaying traffic against candidate settings are often the largest variable item. Operator time covers building the test harness, collecting metrics and reviewing results. Ongoing cost is the staff who watch latency after each vLLM release or traffic change. Ask any quote to split one-time test work from recurring monitoring, and to state how many configurations and traffic profiles it covers.
How long does a batching tuning cycle take?
The length depends mainly on how much traffic you can access and how many workload profiles you need to cover. With a staging environment that can replay recorded or synthetic traffic, a team can sweep a small set of values in a few working sessions. If you must wait for production windows, or if separate interactive and batch workloads share one server, the cycle stretches because each candidate needs repeatable runs. No duration is fixed by vLLM itself, so ask a prospective partner to tie any timeline to the number of profiles, the hardware available for testing and your change approval process.
What do we need to provide for the tuning work?
Three things make the results trustworthy. First, representative traffic: prompt and output length distributions, request arrival patterns and concurrency that match real use, ideally as anonymized logs. Second, model access: the exact model weights, chat template and vLLM version you run in production, plus a comparable GPU environment. Third, metrics retention: enough history from the Prometheus metrics that vLLM exposes at /metrics, including latency histograms and KV cache use, so before and after results can be compared. Confirm retention periods with your monitoring owner before work starts.
Does vLLM itself cost money to use for tuning?
No. vLLM is open-source under the Apache-2.0 license according to its GitHub repository, and the project has no paid edition. What you pay for is the accelerator capacity it runs on, the surrounding infrastructure, implementation work and the people who operate it. Read the license with your legal team to confirm it fits your use, and note that the GPU cost of testing and running the server is the part that scales with your choices.
Which batching settings should a team avoid changing blindly?
Avoid raising max-num-seqs or max-num-batched-tokens to the highest value a benchmark accepts. Larger batches can improve throughput while pushing up time to first token for interactive users, and they can also raise KV cache pressure and preemption when memory runs short. Change one setting at a time, keep the model, GPU and vLLM version fixed, and check the vLLM docs and model recipes for the values they start from. If your results shift after a vLLM upgrade, retest, because defaults and scheduling behavior can change between releases.
When should we bring in a partner for batching work?
Bring in a partner when the workload mixes interactive chat and batch jobs on shared GPUs, when latency targets are tied to a contract, or when your team lacks the time to run repeatable load tests. A partner is also useful when the server sits in a regulated environment that needs documented change control and evidence of the tested settings. DeployOpen plans, implements and supports self-hosted open-source platforms in your own infrastructure, and most engagements are fixed-scope with the scope, deliverables and timelines agreed in writing before work starts.
Decision path for adjusting the two batch limits
The path starts with identifying whether the workload is latency-sensitive or throughput-oriented, which sets the direction for the batch caps. Latency-sensitive traffic moves toward smaller caps, throughput-oriented traffic toward larger ones. Measure the result against the metrics the target depends on, then change one value at a time and retest. Stop when the target is met, and check that the change did not shift the other limit's behavior.
Decision path for choosing and retesting the two batch limits on a vLLM server.
Measuring the effect with vllm bench and production metrics
Measure every batching change before it reaches users. Settings for max-num-seqs and max-num-batched-tokens only prove their worth in numbers from the same workload, so the first step is a baseline run against the current configuration. Use vllm bench serve against the running server with a dataset that resembles your traffic, then record time to first token, time per output token and inter-token latency, along with output token throughput. The companion vLLM online serving docs describe the OpenAI-compatible endpoints the benchmark exercises. Concurrency in the benchmark should be matched to the max-num-seqs value you are testing, because a load generator that never fills the batch cannot show whether a higher ceiling helps or hurts. Keep the model, precision, hardware, prompt mix and output length fixed across runs, and change one setting at a time. The benchmarking topic in this group covers dataset choice, reading the latency metrics correctly and running parameter sweeps in detail.
Use the /metrics endpoint to see what the server did during each run. vLLM exposes Prometheus-format metrics on its API server, covering request counts, token throughput, latency histograms and KV cache usage. Scrape them during the benchmark and again in production, so that the numbers you saw in the client are matched by server-side evidence. KV cache usage shows whether the cache is near its limit when batches grow, and request states show whether work is queuing. The histogram buckets are configurable, so confirm that the boundaries cover the latency range you care about before comparing runs, or the comparison will hide the change you are looking for. Compare runs by putting the same panels side by side, not by comparing single averages. Note that the metrics endpoint is not covered by the --api-key option, so restrict access to it at the network or reverse proxy layer, as the vLLM security docs recommend for endpoints that are not meant for users. Confirm the exact metric names for your vLLM release, since they can change between the releases that ship every two weeks.
How DeployOpen scopes and delivers vLLM batching work
DeployOpen treats vLLM batching and chunked prefill as a measured tuning exercise on your own hardware, not a one-time flag change. We agree the latency and throughput targets in writing, set max-num-seqs and max-num-batched-tokens against your traffic, and document what changed and why.
How we scope
- Engagements are fixed-scope, with the workload types, latency targets and hardware agreed in writing before work starts.
- The written scope names which vLLM server, GPU layout and model versions the batching settings will be tuned against.
- Ongoing tuning and re-testing after vLLM releases are available as a retainer, priced from the written scope.
How we build
- We profile the expected mix of short chat turns and long prompts to choose a starting point for max-num-seqs and max-num-batched-tokens.
- We run controlled load tests with vllm bench serve, comparing interactive and batch profiles and reading TTFT, TPOT and ITL separately.
- We record each setting change, its measured effect and the chunked prefill behavior observed under your concurrency.
How we hand over
- You receive the final server arguments, the reasoning behind each value and the benchmark results that support them.
- Runbooks explain how to change the batching settings safely and which metrics in /metrics to watch after a change.
- We walk your platform and operations engineers through the sweep method so they can repeat it after upgrades.
How we support
- Retesting covers each vLLM minor release you adopt, since scheduler defaults and flags can change between versions.
- Support can include alert review for queueing, preemption and latency regressions tied to batching settings.
- Confirm with DeployOpen during scoping which support hours, response paths and retest frequency apply to your engagement.

