You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for weight-based load balancing in Olla #84
Thanks very much for considering this feature. In our setup, our product connects to multiple Ollama servers, and several of them run the same models. Since the servers have different hardware, capacities, and sometimes different network latencies, it would be really helpful to be able to assign a weight to each endpoint so traffic can be balanced according to their capabilities.
We are currently in the development stage. I initially tried using duplicate URLs, but Olla only accepts the last duplicate. I then set up a reverse proxy with different domains, which worked and Olla distributed traffic equally between them. I also tried the LiteLLM load balancer, which uses latency-based balancing—but this approach sends all requests to the endpoint with the lowest latency, leaving others unused. Additionally, LiteLLM doesn’t support per-endpoint configuration.
Also for our use case, having a load-balancer API (or administrative API) to dynamically add or remove endpoints would be extremely valuable.
For our use case, a combination of weights with #47 would be perfect. I work at a small company and we have not that many compute resources but would like to use what we have. An asymmetric distribution is the only fitting way to handle non-homogeneous HW.
The ideal feature set I would like to have might look like this:
define weight per backend
provide preferences
7B models on slower HW
large models on newer HW
preferences only rank eligible hosts, so fail-over can always happen
provide hard restrictions
not all machines have VRAM for large models
but all machines share a common storage location for downloaded files, so can "see" every available model
could be special case of preference score (or boolean flag hard: true), even preventing fail-over
have olla use information about loaded models to dispatch a request
if a system has the requested model loaded, prefer it as target
if system with model is busy and has a queue, dispatch onto idle system, if available
Any logic keeping track of idle time, request queue and maximum expected queue time would need some tunable heuristics and hard limits to fall back onto well-defined behaviour.
I have a local oMLX use case that matches the loaded-model part of this issue.
oMLX exposes GET /v1/models/status with per-model loaded, is_loading, actual_size, and last_access fields. In practice /v1/models means "available on disk / discoverable", while /v1/models/status tells whether the model is already resident in memory.
The behavior I am after is:
Filter endpoints using Olla's existing model routing strategy.
If any compatible healthy endpoint already has the requested backend model loaded, choose least-connections among those hot endpoints.
If none are hot, fall back to least-connections among all compatible endpoints and let the backend cold-load.
For Olla model aliases, probe the endpoint-specific backend model id after alias resolution.
It adds an omlx-loaded-first balancer that probes /v1/models/status with a short cache, prefers hot endpoints, and falls back to regular least-connections on probe failure or cold candidates.
This is intentionally narrow. If you would prefer a generic loaded-first balancer backed by provider-specific status collectors or registry state, I can rework the approach in that direction.
Meanwhile i believe that weight actually is not the right approach, as weight in the end always means at least a little bit everywhere. There is the proposal for "warm-first" #166 which i think is closer.... but maybe also complicated, not automatically achieving what's intended, as too many variables are at play, as mentionned including HW capabilities. It will probably just not warm up automatically the way the admin would prefer...
Meanwhile i'm believing in the manual way to be a relatively low hanging fruit that in the end may even be better.
As well i believe its core is tied with aliases. In the end as a proxy you intend to abstract.
Assume all models are in principle available on all servers, servers have different capabilites... while you do want to benefit from reuse of already loaded models, not unnecessary purge/reload. Simple logic is trying in predefined sequence per model / alias. ie assume server1&2 to be beefier devices, server3&4 weaker:
So a request comes in for model or alias, this time "qwen3-reranker:8b":
check server3
is it unavail or busy ?
Y -> go to check server4
N -> check model availability:
- model "qwen3-reranker:8b" ?
Y -> execute
N -> iterate over backend models defined in alias
- model unavail ? go to check server4
...
autocheck as before on any servers that have not been part of the predefined sequence.
If not manual, olla would have to be able to evaluate HW, map and prioritize it with models.
this would on any transition of server1 from unhealthy to healthy issue 1 minimal request to server1 requesting model "qwen3.6:35b" so in best case it's always preloaded and can execute without delay even on the first user request.
another variant might be extending set of applicable servers with delay.
model_prios:
qwen3.6:35b:
servers:
server1
server2
wait: 3
servers:
server3
server4
wait: 2
such that on arrival of the request, servers 1&2 are tried. on events like task completion and trigger for schedule & timeout check. if time passed since user request >5s, servers 3&4 are appended to the list.
seconds 0-3: servers 1&2 are tried
seconds 3-5: servers 1-4 are tried
seconds 5-timeout: servers 1-4 & any not listed are tried
Activity
thushan commentedon Nov 18, 2025
Thanks for the suggestion! Would love to know more about the usecase so we can make the implementation work well.
I'm wondering whether based on your suggestion, if something like this (simplified) would work:
This is obviously hardware derived balancing.
Mahdi-A98 commentedon Nov 18, 2025
Thanks very much for considering this feature. In our setup, our product connects to multiple Ollama servers, and several of them run the same models. Since the servers have different hardware, capacities, and sometimes different network latencies, it would be really helpful to be able to assign a weight to each endpoint so traffic can be balanced according to their capabilities.
We are currently in the development stage. I initially tried using duplicate URLs, but Olla only accepts the last duplicate. I then set up a reverse proxy with different domains, which worked and Olla distributed traffic equally between them. I also tried the LiteLLM load balancer, which uses latency-based balancing—but this approach sends all requests to the endpoint with the lowest latency, leaving others unused. Additionally, LiteLLM doesn’t support per-endpoint configuration.
Also for our use case, having a load-balancer API (or administrative API) to dynamically add or remove endpoints would be extremely valuable.
thank you.
Mahdi-A98 commentedon Nov 18, 2025
I also want to mention that the sample configuration you provided would work well for my setup.
moschroe commentedon Apr 2, 2026
For our use case, a combination of weights with #47 would be perfect. I work at a small company and we have not that many compute resources but would like to use what we have. An asymmetric distribution is the only fitting way to handle non-homogeneous HW.
The ideal feature set I would like to have might look like this:
hard: true), even preventing fail-overAny logic keeping track of idle time, request queue and maximum expected queue time would need some tunable heuristics and hard limits to fall back onto well-defined behaviour.
sg-shag commentedon May 30, 2026
I have a local oMLX use case that matches the loaded-model part of this issue.
oMLX exposes
GET /v1/models/statuswith per-modelloaded,is_loading,actual_size, andlast_accessfields. In practice/v1/modelsmeans "available on disk / discoverable", while/v1/models/statustells whether the model is already resident in memory.The behavior I am after is:
I pushed a small proof-of-concept PR here: #152
It adds an
omlx-loaded-firstbalancer that probes/v1/models/statuswith a short cache, prefers hot endpoints, and falls back to regular least-connections on probe failure or cold candidates.This is intentionally narrow. If you would prefer a generic
loaded-firstbalancer backed by provider-specific status collectors or registry state, I can rework the approach in that direction.ccsmart commentedon Jun 3, 2026
Just wanted to chime in "while at it".
I think a similar thing is true with model aliases. Eg:
The following would declare that upgrading is ok:
models:
aliases: ["qwen3.6:27b","qwen3.6:35b"]
But you might want to have the upgrade considered as only if at 27b no server is available / all busy, that is higher priority of 27b.
so maybe:
models:
aliases:
weight: 20
weight: 10
ccsmart commentedon Jun 15, 2026
Meanwhile i believe that weight actually is not the right approach, as weight in the end always means at least a little bit everywhere. There is the proposal for "warm-first" #166 which i think is closer.... but maybe also complicated, not automatically achieving what's intended, as too many variables are at play, as mentionned including HW capabilities. It will probably just not warm up automatically the way the admin would prefer...
Meanwhile i'm believing in the manual way to be a relatively low hanging fruit that in the end may even be better.
As well i believe its core is tied with aliases. In the end as a proxy you intend to abstract.
Assume all models are in principle available on all servers, servers have different capabilites... while you do want to benefit from reuse of already loaded models, not unnecessary purge/reload. Simple logic is trying in predefined sequence per model / alias. ie assume server1&2 to be beefier devices, server3&4 weaker:
model_aliases:
qwen3.6:35b:
- "Qwen3.6-35B-A3B-MTP-GGUF"
- "qwen3.6:35b"
qwen3.6:27b:
- "Qwen3.6-27B-MTP-GGUF"
- "qwen3.6:27b"
- "qwen3.6:35b"
qwen3-reranker:8b:
- "Qwen.Qwen3-Reranker-8B-GGUF-Q8_0"
- "dengcao/Qwen3-Reranker-8B:q8_0"
qwen3-embedding:8b:
- "Qwen3-Embedding-8B-GGUF"
- "qwen3-embedding:8b"
model_prios:
qwen3.6:35b:
- server1
- server2
- server3
- server4
qwen3.6:27b:
- server2
- server1
- server4
- server3
qwen3-reranker:8b:
- server3
- server4
- server1
- server2
qwen3-embedding:8b:
- server4
- server3
- server2
- server1
So a request comes in for model or alias, this time "qwen3-reranker:8b":
Y -> go to check server4
N -> check model availability:
- model "qwen3-reranker:8b" ?
Y -> execute
N -> iterate over backend models defined in alias
- model unavail ? go to check server4
...
autocheck as before on any servers that have not been part of the predefined sequence.
If not manual, olla would have to be able to evaluate HW, map and prioritize it with models.
ccsmart commentedon Jun 15, 2026
given the above, having priorities predefined and knowing the environment one could add an option to endpoints:
discovery:
type: "static"
static:
endpoints:
- name: "server1"
warmup_model: "qwen3.6:35b"
this would on any transition of server1 from unhealthy to healthy issue 1 minimal request to server1 requesting model "qwen3.6:35b" so in best case it's always preloaded and can execute without delay even on the first user request.
ccsmart commentedon Jun 15, 2026
another variant might be extending set of applicable servers with delay.
model_prios:
qwen3.6:35b:
wait: 3
wait: 2
such that on arrival of the request, servers 1&2 are tried. on events like task completion and trigger for schedule & timeout check. if time passed since user request >5s, servers 3&4 are appended to the list.
seconds 0-3: servers 1&2 are tried
seconds 3-5: servers 1-4 are tried
seconds 5-timeout: servers 1-4 & any not listed are tried