Reputation: 123
I basically would like to know how gunicorn workers work. I have a server with 4 workers on a machine, with 4GB RAM, and 2 CPU and having nginx as the frontend serving requests and reverse proxy. I have simultaneous requests being sent to the server.
I wish to know how the workers are being used up, if they are four requests, are they load balanced across the four workers as If 1 requests for each 1 worker?
Also how to check how much memory is used up for each worker? I have set the max requests to 100. So using this 100 max requests. will it reload the entire 4 workers even if 1 worker has reached 100 requests.
How to get more insight of the workers and how the workers memory and no of requests currently in each worker.
Upvotes: 3
Views: 6307
Reputation: 5270
Short answer: Depends on the worker type and gunicorn configuration.
Long answer:
-w
option configures the number of workers, implementation of which varies depending on worker type. Some worker types use threads, others use event loops and are asynchronous. Performance varies depending on the type - in general async via event loop is preferred as it is lighter on resources and more performant.ps
thread output, for example ps -fL -p <gunicorn pid>
. Max connections is per worker from documentation so only the worker that reaches 100 connections will be reloaded.Upvotes: 4