I use gunicorn for my flask app. So far I have been following the guideline so that the numbers of gunicorn workers per machine is (2 x $num_cores) + 1 (they sit behind a load balancer). I am in the process of dockerising the app and my question is: Should I run one gunicorn worker per container (again, the dockerised is load balanced)? Or is there any point in running multiple gunicorn workers per docker container?
It entirely depends on what type of workers you use and the specifics of your app. Some apps will work well with a large number of processes, some with threads, some with a combination of both, some with gevent coroutines, etc. It's down to you to experiment and test your app under load to determine what works well.
Typically, Python will perform better with processes than threads, and the typical number of processes is either the number of cores or 2x + 1. Gevent coroutines only run within one process (and core) but don't have a limit beyond memory requirements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With