Parallel Processing in FastAPI

Viewed 262

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!!

1 Answers

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.

Related