[GH-ISSUE #9103] Ollama is getting slower after a few calls #83611

Closed
opened 2026-05-09 18:43:30 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @JTHesse on GitHub (Feb 14, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9103

What is the issue?

The response time of Ollama is continuously increasing after startup.
First API calls will be answered in a few seconds, which is the normal behavior, but then the response time is increasing to minutes and even hours.
After restarting the container the response time is normal again.

Multiple Versions are affected, I think I have seen this behavior since the release of deepseek-r1.
I'm unsure if a specific model is the reason, or the queuing system has changed or there is a bug in Ollama.

How can I further investigate this or are there already known fixes?
Keep in mind that we are using Ollama for chat as well as coding completions.
Attached you can find my logs:

logs.txt

Relevant log output

[GIN] 2025/02/14 - 12:04:47 | 200 |   2.13385217s |     192.169.1.3 | POST     "/api/generate"
...
[GIN] 2025/02/14 - 12:30:09 | 200 |         7m22s |     192.169.1.3 | POST     "/api/generate"

OS

Linux, Docker

GPU

Nvidia

CPU

Intel

Ollama version

0.5.10

Originally created by @JTHesse on GitHub (Feb 14, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9103 ### What is the issue? The response time of Ollama is continuously increasing after startup. First API calls will be answered in a few seconds, which is the normal behavior, but then the response time is increasing to minutes and even hours. After restarting the container the response time is normal again. Multiple Versions are affected, I think I have seen this behavior since the release of deepseek-r1. I'm unsure if a specific model is the reason, or the queuing system has changed or there is a bug in Ollama. How can I further investigate this or are there already known fixes? Keep in mind that we are using Ollama for chat as well as coding completions. Attached you can find my logs: [logs.txt](https://github.com/user-attachments/files/18799141/logs.txt) ### Relevant log output ```shell [GIN] 2025/02/14 - 12:04:47 | 200 | 2.13385217s | 192.169.1.3 | POST "/api/generate" ... [GIN] 2025/02/14 - 12:30:09 | 200 | 7m22s | 192.169.1.3 | POST "/api/generate" ``` ### OS Linux, Docker ### GPU Nvidia ### CPU Intel ### Ollama version 0.5.10
GiteaMirror added the bugneeds more info labels 2026-05-09 18:43:30 -05:00
Author
Owner

@rick-github commented on GitHub (Feb 14, 2025):

It's not clear from the logs which model you are using for /api/generate. It's llama architecture with 1.35B parameters and Q4_0 quantized but I can't find a matching model in the ollama library. Did you import it from somewhere?

<!-- gh-comment-id:2659708600 --> @rick-github commented on GitHub (Feb 14, 2025): It's not clear from the logs which model you are using for `/api/generate`. It's llama architecture with 1.35B parameters and Q4_0 quantized but I can't find a matching model in the ollama library. Did you import it from somewhere?
Author
Owner

@rick-github commented on GitHub (Feb 14, 2025):

Nevermind, found it: deepseek-coder:1.3b-instruct-q4_0.

<!-- gh-comment-id:2659732325 --> @rick-github commented on GitHub (Feb 14, 2025): Nevermind, found it: [deepseek-coder:1.3b-instruct-q4_0](https://ollama.com/library/deepseek-coder:1.3b-instruct-q4_0).
Author
Owner

@rick-github commented on GitHub (Feb 14, 2025):

Looking at the timestamps, the generate calls were started around the same time:

$ grep /api/generate logs.txt | perl -ne '($time,$elapsed)=(split())[3,7];($h,$m,$s)=split(":",$time);$t0=($h*3600)+($m*60)+$s;if($elapsed=~/((\d+)m)?(([\d.]+)s)?(([\d.]+)ms)?/){$e=($2*60)+$4+($6/1000)};$t1=$t0-$e;$h=int($t1/3600);$m=int(($t1%3600)/60);$s=$t1%60;$s=printf("$time %02d:%02d:%02d $elapsed\n",$h,$m,$s);'
12:04:47 12:04:44 2.13385217s
12:22:15 12:22:12 2.56302439s
12:22:17 12:22:16 578.618425ms
12:22:18 12:22:17 394.740063ms
12:22:39 12:22:24 14.845180102s
12:22:45 12:22:24 20.441994323s
12:22:45 12:22:25 19.67578727s
12:22:45 12:22:25 19.362714227s
12:22:48 12:22:26 21.181072161s
12:23:19 12:22:26 52.019720695s
12:23:51 12:22:29 1m22s
12:24:22 12:22:29 1m53s
12:24:54 12:22:31 2m23s
12:25:26 12:22:33 2m53s
12:25:28 12:22:33 2m55s
12:26:00 12:22:34 3m26s
12:26:06 12:22:36 3m30s
12:26:08 12:22:36 3m32s
12:26:11 12:22:36 3m35s
12:26:43 12:22:38 4m5s
12:26:45 12:22:39 4m6s
12:27:18 12:22:41 4m37s
12:27:51 12:22:42 5m9s
12:28:23 12:22:42 5m41s
12:28:56 12:22:43 6m13s
12:29:29 12:22:44 6m45s
12:29:32 12:22:45 6m47s
12:29:36 12:22:46 6m50s
12:30:09 12:22:47 7m22s

Rather than ollama getting progressively slower, it looks like there was a spike in requests and they got queued up and processed as earlier calls were completed. You could try increasing OLLAMA_NUM_PARALLEL to handle more concurrent requests.

<!-- gh-comment-id:2659867706 --> @rick-github commented on GitHub (Feb 14, 2025): Looking at the timestamps, the `generate` calls were started around the same time: ```console $ grep /api/generate logs.txt | perl -ne '($time,$elapsed)=(split())[3,7];($h,$m,$s)=split(":",$time);$t0=($h*3600)+($m*60)+$s;if($elapsed=~/((\d+)m)?(([\d.]+)s)?(([\d.]+)ms)?/){$e=($2*60)+$4+($6/1000)};$t1=$t0-$e;$h=int($t1/3600);$m=int(($t1%3600)/60);$s=$t1%60;$s=printf("$time %02d:%02d:%02d $elapsed\n",$h,$m,$s);' 12:04:47 12:04:44 2.13385217s 12:22:15 12:22:12 2.56302439s 12:22:17 12:22:16 578.618425ms 12:22:18 12:22:17 394.740063ms 12:22:39 12:22:24 14.845180102s 12:22:45 12:22:24 20.441994323s 12:22:45 12:22:25 19.67578727s 12:22:45 12:22:25 19.362714227s 12:22:48 12:22:26 21.181072161s 12:23:19 12:22:26 52.019720695s 12:23:51 12:22:29 1m22s 12:24:22 12:22:29 1m53s 12:24:54 12:22:31 2m23s 12:25:26 12:22:33 2m53s 12:25:28 12:22:33 2m55s 12:26:00 12:22:34 3m26s 12:26:06 12:22:36 3m30s 12:26:08 12:22:36 3m32s 12:26:11 12:22:36 3m35s 12:26:43 12:22:38 4m5s 12:26:45 12:22:39 4m6s 12:27:18 12:22:41 4m37s 12:27:51 12:22:42 5m9s 12:28:23 12:22:42 5m41s 12:28:56 12:22:43 6m13s 12:29:29 12:22:44 6m45s 12:29:32 12:22:45 6m47s 12:29:36 12:22:46 6m50s 12:30:09 12:22:47 7m22s ``` Rather than ollama getting progressively slower, it looks like there was a spike in requests and they got queued up and processed as earlier calls were completed. You could try increasing [`OLLAMA_NUM_PARALLEL`](https://github.com/ollama/ollama/blob/5296f487a840b2b9ffc28ed9b45d223a32359973/envconfig/config.go#L251) to handle more [concurrent requests](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-does-ollama-handle-concurrent-requests).
Author
Owner

@JTHesse commented on GitHub (Feb 15, 2025):

Thank you, I will try this. It‘s always hard to grasp how much requests are actually being received.

<!-- gh-comment-id:2660583873 --> @JTHesse commented on GitHub (Feb 15, 2025): Thank you, I will try this. It‘s always hard to grasp how much requests are actually being received.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#83611