Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does gunicorn decide which worker gets the request?

In a multi-worker (multi-process) gunicorn setup, how does the master (that is the gunicorn dispatcher process) decide to which worker (process) the request is given to?

Does gunicorn check the workload (processor usage) of each worker in order to decide?

Does it schedule according to the Round-Robin method?

Does it simply remember which worker isn't handling a request at the moment because it had already returned a response earlier so that this is waiting for the next request? And if all workers are busy it simply puts the request in a queue and waits for the first worker to return a response from a previous request and then hands over the request from the queue?

like image 974
Lars Blumberg Avatar asked Nov 07 '22 04:11

Lars Blumberg


1 Answers

I was unable to find any explicit means of dispatching in gunicorn source code, my best bet is that the request is handled by whoever is first to either select in case of sync worker or polls first in case of threaded worker.

like image 191
orhtej2 Avatar answered Jan 01 '23 20:01

orhtej2