how many requests does gunicorn handle in a second

Viewed 40

My flask app is so minimal its just gonna hit an external url, get that response and return that response to the requested client. Flask app named sampleapp is being served in gunicorn by following execution

gunicorn sampleapp:app -w 1 --threads 2 --bind 0.0.0.0:8000

Whats the worker and threads counts actually do. I made gunicorn to work with 1 worker and 2 threads here, how many requests my flask app will handle at minimum in a second. Anyone clarify

1 Answers

Gunicorn uses your system to provide all the load balancing needed for your app. Workers are the central part of gunicorn which process the user request to show them their desired pages. P.S: workers don't mean how many requests there are

You can calculate the no. of workers with this formulae 2N+1 where N is the no. of cores in your CPU. This is optimal for your system and will not put extra load but if your app doesn't have many requests you can use less than that too.

Threads are a new concept from Gunicorn 19 and can be used to process requests in multiple threads. This comes in handy when a request takes too long to complete the task, a thread will notify the master thread that it is still running and shouldn't be killed.

You can learn more of this in the official gunicorn documentation

Related