When do I need vLLM or SGLang?

4 min readMarkdown

You need vLLM or SGLang when one model has to answer many requests at the same time. For one person chatting on a laptop, they bring little and cost a lot of setup.

Built for many users

vLLM and SGLang are open-source serving engines. Each is engine and server in one, with an OpenAI-compatible API out of the box. Both came out of university research groups and are now used to serve models in production at large companies.

They are built around NVIDIA and AMD data-centre GPUs, and they run best on Linux. vLLM serves on port 8000 by default and SGLang on port 30000.

shell
pip install vllm
vllm serve Qwen/Qwen3-8B --max-model-len 32768
shell
pip install "sglang[all]"
python -m sglang.launch_server --model-path Qwen/Qwen3-8B --port 30000

Both load the original Hugging Face weightsWeightsThe full set of a model's parameters, stored in a file.Read more by repository name, or GPU-friendly quantized versions such as AWQ, GPTQ and FP8. They do not use GGUFGGUFThe single-file model format used by llama.cpp and the apps built on it.Read more in normal practice. Where do I download models? covers the formats.

The catch

By default vLLM claims most of the GPU's memory at startup for its KV cacheKV cacheSaved work from earlier tokens, so the model does not reread the whole conversation for every new token.Read more, whether you need it or not. Set --gpu-memory-utilization lower if anything else uses the same GPU.

Continuous batching

The core trick is continuous batching. A simple server finishes one request before starting the next. A batching server runs many requests through the model together, because reading the weights once and using them for many requests costs little more than using them for one.

Continuous batching goes further. New requests join the running batch at the next tokenTokenA chunk of text, usually part of a word. Models read and write in tokens.Read more step. Finished ones leave, so the GPU never waits for the slowest request in a group.

vLLM pairs this with PagedAttention, which stores the KV cache in small pages so memory is not wasted on empty space. SGLang adds RadixAttention, which shares cached prompt prefixes between requests.

That prefix sharing matters for agents. Many agent calls start with the same long system promptSystem promptStanding instructions placed before the conversation.Read more and tool list. SGLang and vLLM can reuse that prefillPrefillThe phase where the model reads your prompt. Limited by compute.Read more across requests instead of computing it again each time.

Single user versus under load

These engines win on total throughput, not on one person's speed. With one user they are about level with llama.cpp on the same GPU, and sometimes behind it. With many users they pull far ahead.

Situationllama.cpp or OllamavLLM or SGLang
One user, one request at a timeSimilar speed, far less setupSimilar speed, more memory claimed up front
A few agents at onceSlots split the context, total throughput rises a littleBatches them, total throughput rises a lot
Many usersEach user's speed falls fast as the queue growsEach user slows a little, total throughput keeps rising
Long shared system promptCached per slotShared across all requests
HardwareAnything, including Macs and CPUsNVIDIA or AMD GPUs on Linux, mainly

The shape is what to remember. Plot total tokens per second against the number of users. llama.cpp's line flattens early. vLLM's and SGLang's keep climbing until the GPU runs out of memory for KV cache.

Rule of thumb

One user, pick by convenience. Three or more people or agents hitting the same model at once, try vLLM or SGLang.

What changes when many people use one model? covers how per-user speed and total throughput trade off, with the maths behind it.

When you have outgrown Ollama

You have outgrown Ollama or LM Studio when any of these is true:

  • Several people share one GPU server and complain it slows down when others use it.
  • You run many agents in parallel and the queue, not the model, is the bottleneck.
  • You need to split one model across several GPUs in one box with tensor parallelismTensor parallelEvery device works on every token. Needs a very fast link.Read more, using --tensor-parallel-size in vLLM.
  • You want metrics, request scheduling and a production deployment story.
The catch

Moving to vLLM means Linux, a supported GPU, Python environments and more memory per model. On a Mac there is no practical path, and on a single consumer GPU the gain for one user is small. How do I set up a team server? walks through a real setup.

Go deeperThat's enough

Why batching is nearly free

Decoding one token means reading every weight from memory once. For one request, the GPU spends most of its time waiting on memory and little time computing. What makes a model fast? explains this.

Add a second request to the same step and the weights are read once for both. The compute doubles, but compute was sitting idle.

So throughput nearly doubles while each user's speed barely changes. This holds until the batch is large enough that compute becomes the limit.

Where the memory goes

Each request in the batch needs its own KV cache. Twenty users at 32K context each need twenty KV caches. That, not the weights, is what caps batch size on most GPUs.

KV cache quantizationQuantizationStoring each weight with fewer bits so the model takes less memory.Read more and smaller contexts let more users fit. How much can the model keep in mind? has the sizes.

vLLM or SGLang

The two overlap heavily and copy each other's ideas. vLLM supports more models and hardware and has the larger community. SGLang is often quicker on workloads with lots of shared prefixes, such as agents and structured output.

We think either is a fine default. Test both on your own traffic before committing.

Multi-GPU and multi-node

Both split a model across GPUs with tensor parallelism and across machines with pipeline parallelismPipeline parallelThe model is cut into consecutive slices across devices. Adds memory, not speed.Read more. That is how teams run models that do not fit one card. How do several GPUs in one box work together? and What are the ways to split work across machines? cover the trade-offs.