'Parallel Processing in FastAPI
Concurrency and parallel processing are two different things.
I know that FastAPI supports concurrency. It can handle multiple api requests concurrently using async and await.
What I want to know is, if FastAPI also supports Multiprocessing and Parallel processing of requests or not ? If yes then how can I implement parallel processing of requests?
I have searched a lot but everywhere I found about concurrency only. I am new to FastAPI. Thanks for your help!!
Solution 1:[1]
When running your app with Uvicorn or Gunicorn, you can specify how many workers/processes you want. In Uvicorn, you just need to pass --workers N as an argument, and in Gunicorn it's pretty much the same, with --workers=N. That will start N processes all receiving requests at the same time.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tonik |
