Monday, 23 October 2023

Gunicorn behavior with worker and thread configuration

I'm currently using Gunicorn version 20.1.0, and I have a question regarding the behavior of Gunicorn when using the following command:

Dockerfile

 CMD ["gunicorn", "--workers", "20", "--threads", "5", "application:application", "--max-requests", "250", "--max-requests-jitter", "50"]

My initial understanding was that this command should instruct Gunicorn to start 20 workers, each supported by 5 threads. After each worker completes 250 requests, it should be terminated and a new worker should be spawned. However, the observed behavior is different.

The number of workers (processes with different PIDs) keeps increasing beyond 60, which eventually leads to memory exhaustion and timeouts. It seems like the workers are not being terminated as expected.

My question is two-fold:

Does Gunicorn create more than 20 workers as I specified in the command? Is Gunicorn failing to terminate workers that have served 250 requests? I would appreciate any insights or suggestions to help me understand and rectify this behavior. Thank you!



from Gunicorn behavior with worker and thread configuration

No comments:

Post a Comment