Reputation: 21218
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:
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?
Upvotes: 12
Views: 4581
Reputation: 2568
If you have access to the prod server use py-spy (https://github.com/benfred/py-spy), super handy.
Upvotes: -1
Reputation: 812
I use the New Relic service:
They have free plan, with 24h data retantion.
Is very easy to setup:
http://newrelic.com/python#installation
Upvotes: -2