-
First Check
Commit to Help
Example Codeimport uvicorn
os.environ["TOKENIZERS_PARALLELISM"] = "false"
if __name__ == "__main__":
uvicorn.run("start:app",
host="0.0.0.0",
port=8080,
workers=2,
limit_concurrency=70,
backlog=300
)DescriptionI have an app using Operating SystemLinux Operating System DetailsUbuntu 20.04 pip packages: FastAPI Versionfastapi==0.61.1 Python VersionPython 3.7.12 Additional ContextThe application is used for implementing prediction using 3 tensorflow models. Two of which are run inside a multiproessing.process call, to achieve parallel execution. |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments
-
The above doesn't makes sense. What you may have heard is to use Gunicorn with Uvicorn workers, which shouldn't be able to solve your issue. import uvicorn
os.environ["TOKENIZERS_PARALLELISM"] = "false"
if __name__ == "__main__":
uvicorn.run("start:app",
host="0.0.0.0",
port=8080,
workers=2,
limit_concurrency=70,
backlog=300
)Also, |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Ups! My bad! Looks like I don't know |
Beta Was this translation helpful? Give feedback.
-
|
No problem @Kludex - you are not alone, I thought setting up |
Beta Was this translation helpful? Give feedback.
-
|
Yeah... I'm going to talk to the maintainers to see if they can improve this on |
Beta Was this translation helpful? Give feedback.
-
|
I don't why you would use uvicorn directly. From uvicorn docs: I usually end up running my development service behind gunicorn (to be consistent with production). |
Beta Was this translation helpful? Give feedback.
-
The reload doesn't work with gunicorn, how do you do it? Is it different than this? Kludex/uvicorn#1193
Nothing changed, is just that now I understand more the reason why is the recommendation. Gunicorn is in charge of keeping the workers alive, killing them when needed, and spawning new ones as that happens. But if your setup already has a technology that guarantees that, then it's not needed. That being said, on this post I think I made the wrong assumption, and it is needed. 😗 In any case, I'll be working on the "process manager" feature on uvicorn. |
Beta Was this translation helpful? Give feedback.
-
|
@Kludex >The reload doesn't work with gunicorn, how do you do it? Is it different than this? |
Beta Was this translation helpful? Give feedback.
-
|
Work without hot reload is not convenient... |
Beta Was this translation helpful? Give feedback.
-
|
For those arriving later, Sebastián just updated the docs: https://fastapi.tiangolo.com/deployment/server-workers/ |
Beta Was this translation helpful? Give feedback.
For those arriving later, Sebastián just updated the docs: https://fastapi.tiangolo.com/deployment/server-workers/