Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to profile Django on Gunicorn in production

I have a memory leak that is hard to reproduce in testing environment. So I'd like to profile my production server for a limited time period to get an overview about which objects take up most memory. It seems that it's not that easy to profile Gunicorn due to the usage of greenlets.

I'm running:

  • Python 2.7.3
  • Gunicorn 18.0
  • Django 1.6

This is my Gunicorn config:

CONFIG = {
    'environment': {
        'DJANGO_SETTINGS_MODULE': 'myapp.settings',
    },
    'user': 'myapp',
    'group': 'myapp',
    'args': (
        '--bind=127.0.0.1:8088',
        '--workers=8',
        '--worker-class=socketio.sgunicorn.GeventSocketIOWorker',
        '--timeout=300',
        '--error-logfile=/var/log/gunicorn/myapp-error.log',
        '--max-requests=100',
        '--log-level=debug',
        'myapp.wsgi:application',
    ),
}

Whats the best way to do memory profiling when running Django with Gunicorn?

like image 305
Wolkenarchitekt Avatar asked Oct 29 '14 09:10

Wolkenarchitekt


1 Answers

I use the New Relic service:

http://newrelic.com/

They have free plan, with 24h data retantion.

Is very easy to setup:

http://newrelic.com/python#installation

like image 105
Ezequiel Bertti Avatar answered Oct 23 '22 10:10

Ezequiel Bertti