Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gunicorn not responding

I'm using Gunicorn to serve a Django application, it was working alright till I changed its timeout from 30s to 900000s, I had to do this because I had a usecase in which a huge file needed to get uploaded and processed (process taking more than 30m in some cases) but after this change Gunicorn goes unresponsive after few hours, I guess the problem is all workers (being 30) will be busy with some requests after this amount of time, the weird thing is it happens even if I don't run that long request at all and it happens with normal exploring in django admin. I wanna know if there's a way to monitor requests on gunicorn and see workers are busy with what requests, I wanna find out the requests that's making them busy. I tried --log-file=- --log-level=debug but it doesn't tell anything about requests, I need more detailed logs.

like image 289
Sassan Avatar asked May 09 '15 08:05

Sassan


People also ask

How do I know if Gunicorn is running?

wsgi:application . systemctl status gunicorn gives you the status of the process.

How many requests per second can Gunicorn handle?

Yes, with 5 worker processes, each with 8 threads, 40 concurrent requests can be served.

How many workers can Gunicorn handle?

Each of the workers is a UNIX process that loads the Python application. There is no shared memory between the workers. The suggested number of workers is (2*CPU)+1 . For a dual-core (2 CPU) machine, 5 is the suggested workers value.

How many Gunicorn workers should I run?

Gunicorn should only need 4-12 worker processes to handle hundreds or thousands of requests per second. Gunicorn relies on the operating system to provide all of the load balancing when handling requests. Generally we recommend (2 x $num_cores) + 1 as the number of workers to start off with.


1 Answers

From the latest Gunicorn docs, on the cmd line/script you can use:

--log-file - ("-" means log to stderr)
--log-level debug

or in the config file you can use:

errorlog = '-'
accesslog = '-'
loglevel = 'debug'

but there is no mention of the parameter format you specified in your question:

--log-file=- 
--log-level=debug

The default logging for access is 'None' (ref), so shot in the dark, but this may explain why are not receiving detailed log information. Here is a sample config file from the Gunicorn source, and the latest Gunicorn config docs.

Also, you may want to look into changing your logging configuration in Django.

like image 125
Drakes Avatar answered Nov 04 '22 00:11

Drakes