Lars Blumberg
Lars Blumberg

Reputation: 21361

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?

Upvotes: 10

Views: 1355

Answers (1)

orhtej2
orhtej2

Reputation: 2165

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.

Upvotes: 1

Related Questions