FastAPI is not using enough threads
See original GitHub issueFirst Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
..
Description
When I send too many requests to my fastapi application it spends most of the time doing nothing which I think is because of threading switching and there being not enough threads in the pool. However, the CPU usage is nowhere near 100% and the memory is less than 10% I am wondering how can I force fastapi to use more threads ? I could not find any resource to set the thread to a higher number in the latest version and what is the default number of threads ?
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.73
Python Version
3.9
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
FastAPI with uvicorn won't allow thread usage to exceed ~65%
Under normal operation, this library will use 8 threads for inference, and will max out all 8 threads 100%. This is the desired...
Read more >SQL (Relational) Databases - FastAPI
By default SQLite will only allow one thread to communicate with it, assuming that each thread would handle an independent request. This is...
Read more >FastAPI and cooperative multi-threading - Ebury Labs
We are using FastAPI, Pydantic, and Kubernetes to build microservices. ... and hope that all of them are not clogged at the same...
Read more >FastAPI - The Good, the Bad and the Ugly - Infolytx
Django and FastAPI respond slower than usual in their first API call. Flask always stays consistent but is much slower than the other...
Read more >tiangolo/fastapi - Gitter
@madkote You said that you had Flask with 4 threads (and 4 cpu/cores ... there a way to solve this without having to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just in case…
You mentioned that you’re using 0.73…
Just do what I said above but instead of changing the value of
total_tokens
, just print it. You’ll see the default value.