Memory leak in Django with Gunicorn and max-requests is already set

10/11/2020

I have a Django application that is integrated with Gunicorn and Prometheus and Kubernetes. It's an application that queries ElasticSearch.

my Gunicorn config is:

exec gunicorn wsgi:application \
    --worker-class gthread \
    --bind 0.0.0.0:15236 \
    --workers 40 \
    --threads 4 \
    --log-level=info \
    --log-file=- \
    --timeout 20 \
    --reload

My Problem

Memory is gradually increasing. And when I add --max-requests 500 config for Gunicorn, my memory still increases and my Pod becomes Evicted! I also deleted all the URLs except for url('', include('django_prometheus.urls')) to ensure that the memory leak is not caused by my code. I also checked the Prometheus directory and It was only 1mb so it is not caused by Prometheus. and DEBUG is set to False.

Questions

What is it possibly causing the memory leak?

And why is max-requests not helping at all and only worsening?

Versions

Django==3.1.1

gunicorn==20.0.4

django-prometheus==2.1.0

-- Ava
django
gunicorn
kubernetes
memory-leaks
prometheus

0 Answers