Handling Ollama overload, queues and 503 errors when requests outpace capacity
A shared Ollama server that slows down or starts returning 503 errors under load is usually hitting its concurrency limits, not failing outright. Three settings decide how much work it accepts at once: OLLAMA_NUM_PARALLEL sets how many requests a loaded model serves at the same time (the documented default is 1 per model), OLLAMA_MAX_LOADED_MODELS sets how many models can stay in memory together (the documented default is 3 times the number of GPUs, or 3 on CPU), and OLLAMA_MAX_QUEUE sets how many requests may wait behind them (the documented default is 512). When the queue is full, new requests are refused, which is the point where clients see 503 responses. Before changing anything, confirm these defaults and the exact 503 behavior against the Ollama FAQ and the release you run, because the defaults and error handling have changed between releases.
Act when the symptom is sustained rather than occasional. A short burst that clears within seconds is normal queueing. Teams should plan action when queue depth stays high for long periods, when users report waits that exceed what their applications tolerate, or when a model is repeatedly unloaded and reloaded because other models compete for memory. Measure before tuning: the server logs and ollama ps show which models are resident and how much of each is on the GPU or CPU, and the usage and timing fields in API responses show whether time goes to load or generation. Raising OLLAMA_NUM_PARALLEL increases memory use per model, so the effect on VRAM must be tested with your actual model and context sizes. Add hardware or a second server when the measured demand exceeds what the current GPU memory can serve in parallel.
Client behavior determines whether a 503 becomes an outage. Retries without backoff multiply the load on a server that is already full, so every application calling the server should use bounded retries with increasing delays and should surface a clear error to the user when the queue stays full. Ask each application owner how their client retries, what timeout it uses, and whether it can route to a second endpoint. Ollama itself does not provide per-user rate limits or a fair-share queue in the settings covered here, so if several teams share one server and need quotas, priority or failover, plan a gateway in front of it. Confirm what your gateway can enforce before you choose it, and test the full path with a deliberate overload in a non-production environment.
How a request moves through Ollama under load
A client request enters Ollama on the API port and is either handed to a free parallel slot for a model that is already loaded, or waits for the model to load. When the server's queue of waiting requests is full, the server returns a 503 response instead of accepting more work. The optional gateway in front is where you can add authentication, rate limits and retry handling before requests reach Ollama. Check the queue depth and load waits first, because they show whether the server or the callers need to change.
Requests reach a parallel slot, wait in a queue, or receive a 503 when the queue is full.
Concurrency and queue settings and when each fits
This table compares OLLAMA_NUM_PARALLEL, OLLAMA_MAX_LOADED_MODELS, OLLAMA_MAX_QUEUE and OLLAMA_HOST by what each changes, what it costs in memory or exposure, and when to raise or lower it. Read each row as a separate lever: the first three decide how requests are served and held, while the host setting decides who can reach the server at all.
| Setting | What it changes and memory trade-off | When to raise it or lower it |
|---|---|---|
| OLLAMA_NUM_PARALLEL | Sets how many requests a loaded model serves at once (default 1). Each parallel slot adds context memory, so more slots means less memory left for the model and its context. | Raise it when several users call the same model and GPU memory has headroom. Lower it to 1 when VRAM is tight or responses must not compete for memory. |
| OLLAMA_MAX_LOADED_MODELS | Sets how many models can stay in memory at once (default 3 per GPU, or 3 on CPU). Each extra resident model consumes memory that would otherwise serve requests. | Raise it when users switch between several models and reloads cause delays. Lower it when models are evicted and reloaded frequently or memory is shared with other workloads. |
| OLLAMA_MAX_QUEUE | Sets how many requests can wait before new ones are rejected (default 512). Queued requests hold connections and delay callers but use little extra memory. | Lower it so overload fails fast with 503 responses and clients can back off. Raise it only when callers can wait and the queue will not hide a capacity shortfall. |
| OLLAMA_HOST | Sets the bind address and port (default 127.0.0.1:11434). Changing it exposes the API beyond the local machine, and the API has no built-in authentication. | Keep the loopback default for single-user work. Move it to a network address only behind a reverse proxy or gateway that enforces authentication and limits. |
| Combined effect on capacity | Parallel slots and resident models share the same memory pool, so raising both at once can push models out of VRAM or into CPU offload. | Change one setting at a time, then watch load behavior and queue depth before changing the next. |
| What to confirm before changing values | Exact behavior on your Ollama version, and how your GPU or CPU memory reacts to each change. | Confirm in the Ollama FAQ and release notes for your version, then test with representative load in a staging environment. |
What Ollama queues, and what it does not
Queued requests wait for one of two things: a free parallel slot on a model that is already loaded, or a model load to finish. Ollama controls this with three settings. OLLAMA_NUM_PARALLEL sets how many requests a model serves at once (the default is 1 per model), OLLAMA_MAX_LOADED_MODELS sets how many models can sit in memory together, and OLLAMA_MAX_QUEUE caps how many requests can wait (the default is 512). Once that cap is reached, new requests are rejected with a 503 rather than held, so the queue is bounded but not unlimited. Confirm these defaults and how the queue counts requests against each model on the exact version you run, because behavior has changed between releases and the FAQ is the place to check first.
Waits grow when these limits meet memory pressure. If a request targets a model that is not loaded, Ollama must free or fit memory before it can start, and a large model load can hold up every request behind it, including requests for models that are already warm. If several models compete for the same VRAM or system RAM, Ollama may unload one to load another, which turns steady traffic into repeated cold loads. Raising OLLAMA_NUM_PARALLEL on a memory-constrained host can make this worse, because each parallel slot needs its own context memory. Measure load time against generation time for each model before you tune any of these values.
What Ollama does not do is decide fairness, priority or per-user limits. It has no built-in notion of which team or key should be served first, and the local API does not authenticate callers, so a single noisy client can fill the queue for everyone. Test the queue behavior for each of your models on the target version with a controlled burst of requests, and record when the 503 responses begin. That result, not the default values, should set your capacity plan and decide whether a gateway in front of the server is needed.
Setting limits and testing overload behavior
This sequence sets concurrency and queue limits on a shared Ollama server, proves they hold under concurrent load, and records the 503 and recovery behavior so operators know what callers will see before users do.
Measure baseline load on the server
Before changing anything, record how the server behaves under normal use. Run ollama ps to see which models are loaded, how much memory each one uses and whether any model is partly running on the CPU. Collect the server logs for a representative period and note request volume, peak concurrent users, and which models get the most calls. Ask each application team for its expected peak concurrency. The step is done when you have a written baseline with peak concurrent requests per model and the memory each loaded model occupies, so later limits are based on measured numbers rather than defaults.
Set OLLAMA_NUM_PARALLEL against available VRAM
Set OLLAMA_NUM_PARALLEL to control how many requests a single model serves at once. Ollama's default is 1 parallel request per model. Each parallel slot needs memory for its context, so a higher value on a GPU with limited VRAM can push a model into CPU offload or fail to load. Change one value in the service environment or container settings, restart the server, and send a short burst of requests. The step is done when ollama ps shows the model still fully on the GPU under that setting and the server logs show no memory allocation errors during the burst.
Set OLLAMA_MAX_LOADED_MODELS against VRAM
Set OLLAMA_MAX_LOADED_MODELS to cap how many models can be resident at the same time. The documented default is 3 times the number of GPUs, or 3 on CPU. Choose a value that your measured model sizes can fit together in VRAM, leaving headroom for context buffers. Loading a model beyond what fits forces unloads and reloads, which show up as slow first responses and load messages in the logs. The step is done when ollama ps lists the models you expect to keep resident, the total memory is below available VRAM, and no model is repeatedly unloaded during the baseline traffic.
Set OLLAMA_MAX_QUEUE
Set OLLAMA_MAX_QUEUE to limit how many requests wait for a slot. The documented default is 512 queued requests. A queue that is too deep hides overload: callers wait long before timing out, and the server holds work it cannot finish in time. A queue that is too shallow sends 503 responses during normal peaks. Choose a value from your baseline, the expected wait per request, and the timeout your clients use. Restart the server and confirm the value is in effect in the startup log lines. The step is done when the configured value is recorded in the change record and the startup logs reflect it.
Load test with concurrent requests
Run a load test against the server, not against a single model call. Use a tool such as a script that sends concurrent requests to the native API at the port your gateway or clients use, with a mix that matches your baseline. Increase concurrency in stages past the total of parallel slots and queue depth. While the test runs, watch ollama ps for loaded models and the server logs for queueing and load events. Keep the test on a non-production server or an agreed window. The step is done when you have a stage-by-stage record of concurrency, latency and response codes.
Confirm 503 responses and recovery
Once concurrency exceeds the queue, confirm that the server returns 503 responses rather than hanging or crashing. Check that the ollama ps output stays consistent, the server process remains running, and the logs record the rejected requests. Then stop the load and confirm that new requests succeed within a normal response time and that the queue drains. Verify that a client with a retry policy does not multiply the load, and that backoff behaves as designed. The step is done when 503 responses appear at the expected concurrency, the server recovers without a restart, and the logs show the queue returning to normal.
Record results and set the change baseline
Write up the test as a record: the baseline numbers, each configured value with its reason, the concurrency at which 503 responses began, the recovery time observed, and any log messages that need monitoring. Store the configuration in the same place as the server's service file or container definition. Name an owner for the limits and a trigger for re-testing, such as a new model, a new client, or a version upgrade. The step is done when the record is stored with the configuration, and the owner has confirmed the values for production use.
How clients should retry 503 responses
Chat interfaces hold a person's attention, so a retry that waits silently feels like a hang. Retries should be few, short and visible to the user. People often resend a message themselves when a reply stalls, so the UI should avoid stacking automatic retries on top of manual ones.
- Show the wait: Display a busy or queued state with a manual retry control instead of replaying the request silently in the background.
- Cap automatic attempts: Allow a small fixed number of automatic attempts, then surface a clear error. Agree the limit with your product and operations teams.
- Back off with jitter: Space attempts using exponential backoff with random jitter so many open browser sessions do not return at the same moment.
- Set timeouts for slow loads: A request can wait in the queue or on a cold model load, so set the connection timeout from measurements on your own models.
- Avoid replaying partial streams: If a streamed reply breaks midway, keep the partial output and ask the user before restarting it.
Check that a test with the queue full produces one clear message and a retry control, not an indefinite spinner.
Batch jobs have no user waiting, so they can accept longer waits. They can also produce the heaviest and most sustained load on the server. A job that retries aggressively across thousands of items can fill the queue controlled by OLLAMA_MAX_QUEUE and delay interactive users, so batch clients should limit submission and treat a 503 as a signal to slow down.
- Limit in-flight requests: Cap concurrent requests per job at a level that matches the parallel setting for the target model, typically controlled by OLLAMA_NUM_PARALLEL, and not at the number of available worker threads.
- Use capped retries with jitter: Apply exponential backoff with jitter and a maximum attempt count per item. Items that exhaust their attempts go to a list for later reprocessing.
- Schedule outside peak hours: Run large jobs in windows agreed with the people who share the server.
- Checkpoint progress: Record completed items so a restart resumes where it stopped instead of repeating finished work.
- Stop the job on repeated 503s: If many consecutive items return 503, pause the whole job rather than sending more items one at a time.
Check the job's request rate and queue behavior during a dry run before the first full run.
Internal applications send requests from many users to one Ollama server, so each application's retry behavior multiplies across all of its callers. Platform teams should set one shared client library or gateway policy so that every application team does not invent its own. The shared policy should be reviewed before applications go live.
- Ship a standard client wrapper: Provide one library with default retry, backoff, jitter and timeout settings that teams inherit without changes.
- Set a retry budget: Limit the share of total requests that can be retries, so a failing dependency cannot multiply load across the server.
- Confirm the request is safe to repeat: Retry only requests that have no side effects. Check tool-calling steps and any writes to other systems before enabling retries.
- Retry only transient failures: Retry 503 responses and timeouts. Treat malformed requests and authentication errors as defects to fix in the application.
- Log every retry: Record each retry with a request identifier and application name so you can see whether a release introduced a retry storm.
Check that each application's retry settings appear in its configuration and that a load test covers the 503 path.
Security and operational risks when overload controls are weak
Overload rarely fails in isolation. The same gaps that let requests pile up also expose the API, hide who caused the load and make limits easy to change without review. The cards below pair each risk with the control that addresses it.
Unauthenticated API exposed by a wider bind
The local API at localhost:11434 has no authentication. Setting OLLAMA_HOST to a wider address without a proxy in front means anyone who can reach the port can submit requests, fill the queue and load models onto your GPUs. Before widening the bind, confirm that an authenticating reverse proxy or gateway sits in front of it and that firewall rules block direct access to port 11434.
Ollama FAQOne user starving the others
With OLLAMA_NUM_PARALLEL at its default of 1 parallel request per model, a single long generation or a large batch job can hold the only slot while every other user waits. Check per-user request volume in your logs and decide whether a gateway should enforce fair use or per-key limits before the shared server is opened to more teams.
Retries amplifying load
When a client receives a 503 and retries immediately, each retry adds another request to a queue that is already full, so recovery takes longer. Client libraries, scripts and chat front ends often retry by default. Confirm the retry count, the backoff delay and the timeout in every integration, and test them against a deliberately saturated test server.
No request logging to reconstruct load
Without request logs at the proxy or gateway, a spike in 503 responses cannot be traced to a user, an application or a model. Record the caller identity, model name, status code and timing for each request and send them to a central system. Plan retention with your security team, since these logs also serve as evidence during incident review.
Cloud features and keys in the request path
Some models and features send requests to ollama.com rather than the local runtime. Direct cloud inference requires an API key sent as a Bearer token, and that key can end up in client configuration, logs or shared scripts. Set OLLAMA_NO_CLOUD=1 where cloud use is not approved, and confirm which keys exist, who holds them and where they are stored.
Ollama API authenticationLimit changes without change control
Values such as OLLAMA_NUM_PARALLEL, OLLAMA_MAX_LOADED_MODELS and OLLAMA_MAX_QUEUE are often raised during an incident and never reverted. Store these settings in version-controlled service configuration, require a reviewed change for each one, and record the reason, the owner and the rollback value. Re-test the 503 behavior after every change.
- Default queued requests
- 512
When to add capacity, and when to add a gateway
Tune the settings you already have before you buy hardware or add infrastructure. Queueing on a shared Ollama server usually comes from a mismatch between how many requests arrive and how the server is configured to handle them, and that mismatch is often cheaper to fix than a new GPU. Check OLLAMA_NUM_PARALLEL, OLLAMA_MAX_LOADED_MODELS and OLLAMA_MAX_QUEUE against your actual traffic, then watch ollama ps during peak use to see which models stay resident and which are being swapped in and out. If requests wait because the same few models keep reloading, the fix is in model residency and scheduling, not raw compute. Confirm the current default values for these variables in the Ollama FAQ and in the release notes for the version you run, because defaults have changed between releases.
Add a GPU or a second server when queueing persists after tuning and the bottleneck is compute or memory. Sustained queueing at peak, with models already loaded and parallel slots already in use, is the signal. Measure load time against generation time and VRAM headroom before deciding, because a second server only helps if clients can reach it, and a single endpoint behind a load balancer still needs a routing policy for which models live where. Hardware cost is one-time, but power, rack space, support hours and the operating effort of a second node recur. Ask any partner to quote the sizing work separately from the hardware purchase.
Add a gateway when the problem is control rather than throughput. Ollama's local API has no authentication, so per-user quotas, API keys, routing across several servers, request logging and usage metrics belong in a layer in front of it. The gateway category is often called an AI gateway or API gateway, and several open-source options exist, including LiteLLM and Apache APISIX, which DeployOpen also implements. Choose by the controls you need, not by brand. DeployOpen can plan and implement the gateway, the routing rules and the metrics pipeline in infrastructure you control, with the scope and retry rules agreed in writing before work starts.
Questions teams ask before fixing Ollama overload
What does it cost to fix Ollama overload on a shared server?
The cost depends on how much of the work is tuning, how much is capacity, and how much is a gateway. Tuning the server (concurrency settings, queue depth, model placement) is usually the smallest part. Load testing, log analysis and a written change plan take more time, and adding GPUs or a second server adds hardware and power costs that recur. Ollama itself is free to run on your own hardware, since its pricing page states that local model running is always unlimited, so spending goes to hardware, staff time or a partner's fixed-scope engagement. Ask any partner for a quote that separates one-time work (assessment, configuration, test scripts, runbook) from recurring work (retainer support, retesting after upgrades).
How long does a tuning and load test cycle take?
Duration is set by the environment, not by a fixed formula. The main drivers are how many models you serve, how many GPUs and how much memory each host has, how varied your traffic is, whether you already collect logs and usage metrics, and how many approval steps your change process requires. A single host with one model and existing metrics moves much faster than a multi-host setup with several models and no baseline. Each cycle usually includes a baseline run, a change, a retest and a review of the 503 and queue behavior. Ask for the number of test rounds and the environments they run in, and confirm the schedule in writing before work starts.
What must our team provide before an overload review starts?
The review needs enough data to explain why requests queue or fail. Prepare the following:
- Hardware details for each host: GPU model, VRAM, CPU, RAM and the storage holding model files
- The Ollama version and how it was installed (package, script or container image)
- The environment variables in use, especially OLLAMA_NUM_PARALLEL, OLLAMA_MAX_LOADED_MODELS and OLLAMA_MAX_QUEUE
- A traffic profile: peak request rate, typical prompt and response sizes, and which models each application calls
- Server logs and any 503 counts from clients or proxies over a representative period
Also name a person who can approve config changes during testing.
Can our own engineers fix Ollama overload without a partner?
Yes, if the team can read logs, run a repeatable load test and change configuration under a change process. The settings involved are documented: OLLAMA_NUM_PARALLEL, OLLAMA_MAX_LOADED_MODELS and OLLAMA_MAX_QUEUE, with defaults the FAQ lists as 1 parallel request per model, 3 times the GPU count (or 3 on CPU) and 512 queued requests. The harder parts are separating queue wait from model load time, judging whether a GPU is actually shared between models, and deciding when the hardware is the limit. A partner is most useful when the team lacks load testing tools, has no baseline, or needs an independent record for a security or compliance review.
When does a gateway project become worth scoping?
A gateway is worth scoping when the problem is no longer one server's settings but how many clients share several backends. Typical signals are multiple hosts that need one endpoint, per-user or per-application quotas, usage limits that must be enforced before requests reach the GPU, or a need to route between local and approved external models. Tuning the queue will not solve those needs. A gateway adds its own components to operate, logging and access controls, so scope it as a separate project. Confirm which gateway fits your access model before committing to one.
Does a queue limit protect the server or just hide the problem?
A queue limit protects the server from unbounded memory growth, but it does not add capacity. When OLLAMA_MAX_QUEUE is reached, new requests are refused with 503 responses, so clients see errors instead of long waits. A high limit can hide overload behind long latency, and a low limit can cause errors during short bursts that the hardware could absorb. Set the value from measured queue wait times and client timeouts, and document the choice so the on-call team knows what a 503 means.
What security issues come with fixing overload on a shared server?
Changes to bind addresses, proxies and retry logic can expose the API or amplify load. The local API at port 11434 has no authentication by default, so any gateway or proxy you add must enforce access before requests reach it. Keep OLLAMA_HOST on localhost unless a controlled path exists, and review logs for unexpected callers during testing. Load tests should run in a non-production environment with synthetic prompts, so no real user data enters the test logs.
How DeployOpen scopes overload fixes for shared Ollama servers
DeployOpen approaches overload on a shared Ollama server as an operations problem with a written scope, not a single setting change. We plan the work inside your own infrastructure, document the queue and capacity settings, and hand over a server your team can run and explain.
How we scope
- Review how many users and applications call the server, and which models they load.
- Record current OLLAMA_NUM_PARALLEL, OLLAMA_MAX_LOADED_MODELS and OLLAMA_MAX_QUEUE values and where 503 responses appear.
- Agree in writing whether the fix covers settings, capacity planning, a gateway in front, or all three.
How we build
- Tune concurrency and queue limits against the hardware and model mix you already run.
- Set up test load that reproduces queueing and confirms how the server responds once the queue is full.
- Add a gateway or proxy layer only where the scope calls for it, with routing and retry rules defined.
How we hand over
- Document each setting, its default, the value chosen and the reason it was chosen for your workload.
- Write runbooks for reading queue depth, identifying overload in logs, and deciding when to add capacity.
- Walk your platform and operations staff through the tests so they can rerun them after changes.
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- Ask any partner to confirm in the quote which environment, access and approvals your team must provide.

