3 Matching Annotations
- Dec 2023
-
horaceguy.pages.dev horaceguy.pages.dev
-
Gunicorn and multiprocessing
Gunicorn forks a base process into
n
worker processes, and each worker is managed by Uvicorn (with the asynchronous uvloop). Which means:- Each worker is concurrent
- The worker pool implements parallelism
This way, we can have the best of both worlds: concurrency (multithreading) and parallelism (multiprocessing).
-
-
tonybaloney.github.io tonybaloney.github.io
-
Another important point is that multiprocessing is often used in a model where the processes are long-running and handed lots of tasks instead of being spawned and destroyed for a single workload. One great example is Gunicorn, the popular Python web server. Gunicorn will spawn “workers” using multiprocessing and those workers will live for the lifetime of the main process. The time to start a process or a sub interpreter then becomes irrelevant (at 89 ms or 1 second) when the web worker can be running for weeks, months or years. The ideal way to use these parallel workers for small tasks (like handle a single web request) is to keep them running and use a main process to coordinate and distribute the workload
-
- Apr 2020
-
code.visualstudio.com code.visualstudio.com
-
To use Gunicorn as your web server, it must be included in the requirements.txt file as an app dependency. It does not need to be installed in your virtual environment/host machine.
-