New Tool Radar

Local AI

How to Set OLLAMA_NUM_PARALLEL for Parallel Ollama Requests

Raise OLLAMA_NUM_PARALLEL so Ollama answers several requests at the same time.

Schematic illustration with three step boxes: Check the default; Set the variable; Send parallel requests.

By default Ollama handles one request at a time per model, so a second request waits for the first to finish. OLLAMA_NUM_PARALLEL sets how many requests run at once, which matters when several people, or several of your own tools, share one Ollama server. This guide raises it and tests the change.

Before you start

  • Ollama installed and running, with a model already pulled.
  • Enough memory for several copies of the context at once; each parallel request adds KV cache.
  • A terminal and a way to send two requests at once, such as two terminal windows.

Check the current behaviour

Send two prompts at the same time from two terminals with ollama run or curl to the API. With the default, the second answer waits for the first. Note the wall-clock time for both to finish.

Set the variable and restart

Set the number of parallel requests, for example 2, and restart Ollama:

OLLAMA_NUM_PARALLEL=2 ollama serve

On Linux with systemd, stop the service, add the variable to the service environment, and start it again.

Send parallel requests again

Repeat the two-at-once test. Both answers should now progress together, and the total time for the pair should be less than running them one after another.

Worked example

Worked example: send the same summary prompt for two different 500-word texts at the same time, with OLLAMA_NUM_PARALLEL=2. The pair should finish in roughly the time of one long run plus a small overhead, instead of the sum of two runs.

Expected result

UNTESTED in this guide: no server was restarted while writing it. The expected result is that two simultaneous requests both progress, and the pair finishes faster than two sequential runs.

Limitations

Parallel requests share the GPU and the KV cache, so each one runs slower than it would alone, and a high value can push the machine out of memory. Start at 2 and raise it only if memory allows.

Sources

See all