When more requests arrive than Ollama can run, the extra ones wait in a queue. That queue has a limit, 512 by default, and requests past it are refused. If a busy app sends bursts of requests to your server, raising OLLAMA_MAX_QUEUE lets the burst wait in line instead of failing. This guide raises it and tests a burst.
Before you start
- Ollama installed and running.
- A client that can send many requests at once, or a small script using curl.
- A terminal and the way you start Ollama on your system.
Confirm the default
The default queue limit is 512. You only need to change it if you see refused requests during bursts, or if your app logs queue errors. Do not raise it just because the number looks small.
Set the variable and restart
Set a higher limit, for example 1024, and restart Ollama:
OLLAMA_MAX_QUEUE=1024 ollama serve
On Linux with systemd, stop the service, add the variable to the service environment, and start it again.
Test a burst
Send a burst of short requests at once and count how many get answers and how many are refused. With the higher limit, a burst that used to lose requests should now queue and finish, though the last ones will wait longer.
Worked example
Worked example: fire 600 tiny prompts (for example, “Reply with the word done.”) at the server in one burst. With the default limit of 512, some of the burst is refused; with OLLAMA_MAX_QUEUE=1024, all 600 should be answered, with the later ones waiting in the queue.
Expected result
UNTESTED in this guide: no server was restarted while writing it. The expected result is that a 600-request burst is fully answered after the change, with the later requests waiting in the queue.
Limitations
A bigger queue means longer waits for the requests at the back, and a very large queue can hold memory for a long time. Raise the limit to cover your real bursts, not to a huge number by default.
