# When do I need vLLM or SGLang?

> When several people or agents share one model at once. These servers batch requests together and keep throughput high under load.

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](https://localagi.co/local-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.

```bash
pip install vllm
vllm serve Qwen/Qwen3-8B --max-model-len 32768
```

```bash
pip install "sglang[all]"
python -m sglang.launch_server --model-path Qwen/Qwen3-8B --port 30000
```

Both load the original Hugging Face weights by repository name, or GPU-friendly quantized versions such as AWQ, GPTQ and FP8. They do not use GGUF in normal practice. [Where do I download models?](https://localagi.co/where-models-come-from) covers the formats.

**The catch.** 
By default vLLM claims most of the GPU's memory at startup for its KV cache, 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 token 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 prompt and tool list. SGLang and vLLM can reuse that prefill 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.

| Situation | llama.cpp or Ollama | vLLM or SGLang |
| --- | --- | --- |
| One user, one request at a time | Similar speed, far less setup | Similar speed, more memory claimed up front |
| A few agents at once | Slots split the context, total throughput rises a little | Batches them, total throughput rises a lot |
| Many users | Each user's speed falls fast as the queue grows | Each user slows a little, total throughput keeps rising |
| Long shared system prompt | Cached per slot | Shared across all requests |
| Hardware | Anything, including Macs and CPUs | NVIDIA 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?](https://localagi.co/one-user-to-many) covers how per-user speed and total throughput trade off, with the maths behind it.

## When you have outgrown Ollama

You have outgrown [Ollama](https://localagi.co/ollama) or [LM Studio](https://localagi.co/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 parallelism, 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?](https://localagi.co/team-server) walks through a real setup.

## Go deeper

### 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?](https://localagi.co/what-makes-it-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 quantization and smaller contexts let more users fit. [How much can the model keep in mind?](https://localagi.co/context-window) 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 parallelism. That is how teams run models that do not fit one card. [How do several GPUs in one box work together?](https://localagi.co/multi-gpu) and [What are the ways to split work across machines?](https://localagi.co/three-ways-to-cluster) cover the trade-offs.
