refusal rate
Subscribe

OLLAMA_NUM_PARALLEL sets how many requests one loaded model serves at once. Default 1; each slot adds a full num_ctx of KV cache. How to set it, when to stop.

[ fig. 01 — reference ]48×5
[ fig. 01 — reference ]16×5

Short answer

OLLAMA_NUM_PARALLEL is the number of requests a single loaded Ollama model processes at the same time. It defaults to 1 (since v0.10.0). Every extra slot reserves another full num_ctx of KV cache, so memory grows with num_ctx × num_parallel. Use 1 for one user or agent, 2–4 for a few concurrent clients if VRAM allows, and move to vLLM or SGLang when concurrency is the job.

Default
1 (since v0.10.0)
Scope
Per loaded model
Memory
KV cache for num_ctx × num_parallel
OLLAMA_MAX_QUEUE default
512, then HTTP 503

Key takeaways

  1. The default is 1. Older guides that say "4, or 1 if memory is low" describe Ollama before v0.10.0 (July 2025).
  2. The setting is per loaded model, not per server. Two different models still run side by side, up to OLLAMA_MAX_LOADED_MODELS.
  3. Ollama starts the runner with num_ctx × num_parallel tokens of context, so each slot costs a full context's worth of KV cache.
  4. Some architectures are forced back to 1 regardless of the setting, including Qwen3.5, Qwen3-Next, Qwen3-VL, LFM2 and Nemotron-H, and the MLX engine runs requests sequentially.
  5. OLLAMA_MAX_QUEUE (default 512) only caps requests waiting for a model to load; when it overflows the API returns HTTP 503.

What does OLLAMA_NUM_PARALLEL do?

OLLAMA_NUM_PARALLEL sets how many requests each loaded model processes at the same time; requests beyond that wait in line. The FAQ defines it as “the maximum number of parallel requests each model will process at the same time” (Ollama docs). Under the hood, Ollama passes the value to its llama.cpp-based runner as a number of slots. Each slot holds one conversation’s KV cache, and the runner batches the active slots through the GPU together.

Two things follow from that design, and most confusion about ollama_num_parallel comes from missing one of them:

  • It is per model, not per server. With OLLAMA_NUM_PARALLEL=1, a request to qwen2.5-coder:7b and a request to llama3.2 still run at the same time, because they hit two different runners. Capping the whole server takes OLLAMA_MAX_LOADED_MODELS=1 as well.
  • Parallel is not faster per request. Slots share the same GPU compute. You gain aggregate throughput (tokens per second summed across clients) and lose per-request speed.

Concurrency itself arrived in Ollama v0.2.0 in July 2024, announced as serving “multiple requests at the same time, using only a little bit of additional memory for each request” (release notes). The “little bit” depends heavily on context length, as shown below.

What is the ollama_num_parallel default, and how does Ollama choose it?

The default is 1, and Ollama no longer picks it automatically. The current source sets NumParallel = Uint("OLLAMA_NUM_PARALLEL", 1) (config.go, v0.40.13), and the v0.10.0 release notes (July 2025) say “Parallel request processing now defaults to 1” (release).

Before v0.10.0 the variable defaulted to 0, which meant “auto”: the scheduler used 4 slots when memory allowed and fell back to 1 otherwise. Many guides that still rank for this query describe that old behaviour, which is why you will read “the default is 4” in places.

Even when you raise the value, the scheduler overrides it to 1 in these cases (sched.go, v0.40.13):

CaseWhat Ollama does
Embedding models (no completion capability)Always 1 slot
Architectures mllama, qwen3vl, qwen3vlmoe, qwen35, qwen35moe, qwen3next, lfm2, lfm2moe, nemotron_h, nemotron_h_moe, nemotron_h_omniForced to 1, logs “model architecture does not currently support parallel requests”
Models on the MLX engine (Apple Silicon preview)Runner is started without a parallel flag; requests run one after another (#17280)

The forced-1 list includes the Qwen3.5 family, so if your coding model is a Qwen3.5 build, OLLAMA_NUM_PARALLEL=4 does nothing for it today.

How much memory does each parallel slot cost?

Each slot costs one full num_ctx of KV cache. When it loads a model, Ollama computes the runner’s context as the effective num_ctx multiplied by num_parallel (effectiveLlamaServerContext in sched.go). The FAQ puts it the same way: memory needs scale with OLLAMA_NUM_PARALLEL × OLLAMA_CONTEXT_LENGTH (docs). Weights are loaded once; only the cache multiplies.

The KV cache per token for a standard transformer is 2 (keys and values) × layers × KV heads × head dimension × bytes per value. From the published configs, at the default f16 cache:

ModelLayers / KV heads / head dimKV per tokenPer slot at 4kPer slot at 8kPer slot at 32k
Qwen2.5-Coder 7B28 / 4 / 12856 KiB0.23 GB0.47 GB1.88 GB
Qwen2.5-Coder 32B64 / 8 / 128256 KiB1.07 GB2.15 GB8.59 GB

Layer and head counts come from the Qwen2.5-Coder-7B and 32B configs. The figures are arithmetic, not measurements, and leave out compute buffers.

[ fig. 01 — Weights (about 20 GB, Ollama library listing) plus f16 KV cache at num_ctx 8192 per slot. Computed from the model config; excludes compute buffers. ]
With Qwen2.5-Coder 32B at Q4_K_M and an 8k context per slot, 1 slot needs about 22 GB, 2 slots 24 GB, 4 slots 29 GB and 8 slots 37 GB, so a 24 GB card fits 1 slot and a 32 GB card fits 4.

The trap is Ollama’s automatic context length. If you don’t set num_ctx or OLLAMA_CONTEXT_LENGTH, Ollama picks 4k below 24 GiB of VRAM, 32k from 24 to 48 GiB, and 256k at 48 GiB and above (docs), capped at the model’s training context. On a 32 GB card, the 32B model above would get 32k per slot, so 4 slots ask for about 34 GB of cache, before weights. When the context is automatic, the scheduler steps it down after a failed load, so you may silently get a shorter context per slot instead of an error. Set the context explicitly when you raise parallelism. Ollama context length covers choosing the value, and OLLAMA_KV_CACHE_TYPE=q8_0 roughly halves the cache cost (see kv cache quantization).

How do you set OLLAMA_NUM_PARALLEL on macOS, Linux, Windows and Docker?

Set it in the environment of the Ollama server process, then restart the server. Setting it in the terminal where you run ollama run does nothing, because that is only the client. The steps below follow the FAQ.

macOS (app):

plaintext
launchctl setenv OLLAMA_NUM_PARALLEL 4
launchctl setenv OLLAMA_CONTEXT_LENGTH 8192
# quit and reopen the Ollama app

Linux (systemd service):

plaintext
sudo systemctl edit ollama.service
# add under [Service]:
# Environment="OLLAMA_NUM_PARALLEL=4"
# Environment="OLLAMA_CONTEXT_LENGTH=8192"
sudo systemctl daemon-reload
sudo systemctl restart ollama

Windows: quit Ollama from the tray, open “Edit environment variables for your account”, add OLLAMA_NUM_PARALLEL with value 4, then start Ollama again. From a terminal, setx OLLAMA_NUM_PARALLEL 4 writes the same user variable.

Docker:

plaintext
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 \
  -e OLLAMA_NUM_PARALLEL=4 -e OLLAMA_CONTEXT_LENGTH=8192 \
  --name ollama ollama/ollama

Manual serve: OLLAMA_NUM_PARALLEL=4 ollama serve.

To confirm, read the server log. Ollama prints its resolved config, including OLLAMA_NUM_PARALLEL, at startup, and logs the runner’s parallel value when a model loads. If the startup line shows the old value, the variable never reached the server.

Why are requests still queued or rejected? (OLLAMA_MAX_QUEUE, MAX_LOADED_MODELS)

Requests queue whenever all slots of the target model are busy, and get a 503 only when the scheduler’s own backlog is full. Three settings interact:

  1. OLLAMA_NUM_PARALLEL: busy slots. Request N+1 to the same model waits for a slot.
  2. OLLAMA_MAX_LOADED_MODELS: how many different models can be resident. The FAQ gives the default as 3 per GPU (or 3 for CPU inference); the code uses defaultModelsPerGPU = 3. A new model must fit fully in VRAM to load next to others; otherwise requests wait while an idle model unloads (docs).
  3. OLLAMA_MAX_QUEUE: default 512. When the scheduler’s pending channel is full, Ollama returns HTTP 503 with “server busy, please try again. maximum pending requests exceeded” (sched.go).

The catch with ollama_max_queue: it does not cap requests to a model that is already loaded. Those go straight to the runner and wait on the slot semaphore, which has no depth limit. A user who set both values to 1 still saw unlimited queuing, and maintainer dhiltgen called it “a side effect of the way the scheduler is implemented”; a contributor reproduced it on main in June 2026 (#7758). If you need real backpressure, enforce it in a proxy in front of Ollama.

Models also unload after their keep-alive window, which turns the next request into a cold load; Ollama keep alive covers that timing.

When should you switch to vLLM or SGLang instead?

Switch when concurrency is the workload rather than an occasional overlap. Ollama reserves a fixed num_ctx block per slot whether or not a request uses it. vLLM and SGLang allocate KV cache in pages on demand and batch continuously, so the same VRAM holds more simultaneous requests. Reasonable triggers:

  • You serve a team or a pipeline that routinely keeps more than a few requests in flight. See self hosted LLM server for team setups.
  • You need predictable latency under load, or real queue limits and metrics.
  • Your model’s architecture is on Ollama’s forced-1 list.

Ollama still wins for one developer, a laptop, CPU fallback and quick model switching. If you are choosing between the two engines, vLLM vs SGLang compares them.

What do developers report in practice?

Practitioner reports agree that parallel slots trade per-request speed for total throughput, and that higher values break more often than the docs suggest:

  • Parallel can be slower end to end. A user running gpt-oss:20b on a 45+ GB NVIDIA setup with OLLAMA_NUM_PARALLEL=2 measured three requests at about 30 s sequentially and about 43 s in parallel, with GPU utilization at 40–55%. Another user on two RTX 3090s saw a 60-query batch finish in about the same 10 minutes at 1 or 2, and worse at 4 when a second copy loaded on the other GPU. A collaborator’s reading of the logs: individual requests slow down while aggregate tokens per second stays roughly flat (#12107, community reports).
  • High slot counts hit tensor limits. On 2× GH200, Ministral-3 14B with a 128k context crashed at parallel 8 but not 7, with an aggregate KV size of 1,048,576 tokens; others reported gemma4:26b working at 2 and crashing at 4. Suggested workarounds were one fewer slot or a slightly smaller context (#13887, community reports).
  • “Not working” is often per-model scope. One user set OLLAMA_NUM_PARALLEL=1 in a container and still saw two agent sessions generating at once; the explanation offered in the thread was that each agent turn is a separate request and parallelism is per model (#19262, open).
  • Throughput gap versus vLLM. One Hacker News commenter reported vLLM delivering up to 3.2× the requests per second of Ollama on identical hardware, while calling Ollama good enough for a handful of concurrent users (HN). Another noted that on a 70B Q4_K_M you have to size the context window around the parallel count, not around one user (HN).

What should you set it to?

SituationSuggested value
One developer, one chat or one coding agent1 (default)
Agent that fans out sub-tasks, or 2–4 teammates sharing one GPU2–4, with an explicit 4k–8k num_ctx, after checking the memory table
Model on the forced-1 list or the MLX engineLeave it; the value is ignored
Steady multi-user traffic, latency targetsMove the model to vLLM or SGLang

Raise it one step at a time and watch ollama ps: if the model drops from 100% GPU to a CPU/GPU split, the extra slot cost you more than it gained.

FAQ

What is the OLLAMA_NUM_PARALLEL default?

1, since v0.10.0. Earlier versions auto-selected 4 or 1 based on available memory.

Is OLLAMA_NUM_PARALLEL=4 a good setting?

Only if four full contexts of KV cache fit in VRAM next to the weights and the architecture supports it. For a 7B coder at 8k it adds under 2 GB; for a 32B coder it adds about 8.6 GB.

Why is OLLAMA_NUM_PARALLEL not working?

The usual causes: the variable was set in your shell rather than the server’s environment, the server wasn’t restarted, the model’s architecture is forced to 1, the model runs on the MLX engine, or you are seeing two different models run side by side.

Can I set OLLAMA_NUM_PARALLEL per model?

No. It is a server-wide value applied to each loaded model; a per-model option is an open feature request (#4894). Run a second Ollama instance on another port if you need different values.

What does OLLAMA_MAX_QUEUE do?

It limits how many requests can wait in the scheduler (default 512) before Ollama answers HTTP 503. It does not limit requests waiting on an already-loaded model.

Sources (10)
  1. Ollama docs: FAQ, How does Ollama handle concurrent requests?
  2. Ollama docs: Context length (VRAM-based defaults)
  3. ollama/ollama v0.40.13 source: envconfig/config.go (defaults)
  4. ollama/ollama v0.40.13 source: server/sched.go (parallel slots, forced-1 architectures, queue)
  5. Ollama v0.10.0 release notes: parallel request processing now defaults to 1
  6. Ollama v0.2.0 release notes: concurrency support
  7. ollama/ollama issue #12107: Concurrent requests take longer than sequential (community report)
  8. ollama/ollama issue #7758: OLLAMA_MAX_QUEUE does not limit requests to the same model
  9. ollama/ollama issue #17280: Concurrent requests in the MLX engine (community report)
  10. Qwen2.5-Coder-32B-Instruct config.json (layers, KV heads)

Keep reading

[ fig. 02 — how-to ]18×8

How do you set the context length in Ollama, LM Studio and llama.cpp?

Nov 2, 2026 · How-to

In Ollama, set the context length with the OLLAMA_CONTEXT_LENGTH environment variable, the app's slider, or a num_ctx parameter in a Modelfile or API request. In LM Studio, set it in the model's load settings or with lms load --context-length. In llama.cpp, pass -c. Ollama defaults to 4k tokens on GPUs under 24 GiB of VRAM, and its docs recommend at least 64k for coding agents.

Read
[ fig. 03 — reference ]18×8

How do you keep an Ollama model loaded in memory (keep_alive)?

Nov 2, 2026 · Reference

Ollama keeps a model in memory for 5 minutes after its last request, then unloads it. Set OLLAMA_KEEP_ALIVE on the server (for example 24h, or -1 for forever) to change the default, or send keep_alive on each request, which always wins. keep_alive 0 or ollama stop unloads immediately. Most 'not working' reports come from a client sending its own keep_alive, an env var the service never sees, or a value Ollama cannot parse.

Read
[ fig. 04 — comparison ]18×8

vLLM vs SGLang: which inference server should you run?

Nov 2, 2026 · Comparison

vLLM and SGLang are the two main open-source servers for running open-weight LLMs for many users at once. On unique prompts they benchmark within a few percent of each other. SGLang pulls ahead when requests share long prefixes, as in agents, RAG and multi-turn chat, thanks to RadixAttention. vLLM has the broader model, quantization and hardware-plugin coverage, and is the safer default when your traffic has no dominant shared prefix.

Read