benoitc / gunicorn

gunicorn 'Green Unicorn' is a WSGI HTTP Server for UNIX, fast clients and sleepy applications.
http://www.gunicorn.org
Other
9.87k stars 1.75k forks source link

Big app (django) that starts 10+ seconds is reason of timeouts when reach max-request limit #3307

Open tbicr opened 1 month ago

tbicr commented 1 month ago

I have quite big django app running on gevent gunicorn. This application can starting 10+ seconds.

This application has issue with memory leaks, but --max-requests allows to handle this issue perfectly.

However I have other issue with it, when I reach max-requests limit, then requests to pod with gunicorn start getting timeouts for next ~30 sec, that can be reason of quite big error rate.

I created dummy test app https://github.com/tbicr/django_g, that sleep for 10 seconds to emulate big application load time.

num of requests: 180
num of error: 20  <- this is bad
num duration from 0ms to 20ms: 33
num duration from 20ms to 50ms: 57
num duration from 50ms to 100ms: 56
num duration from 100ms to 200ms: 13
num duration from 200ms to 500ms: 1
num duration from 500ms to 1000ms: 0
num duration from 1000ms to 2000ms: 0
num duration from 2000ms to 5000ms: 0
num duration from 5000ms to 10000ms: 0
num duration more 10000ms: 20  <- this is bad

--preload option doesn't help there.

However when I warm all workers all looks fine.

So is it possible to warm all gunicorn workers?

Warm can works fine, but if worker will be available to handling requests before warm it still can be reason of timeouts, so second question is it possible to warm gunicorn before receiving requests?