Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use python's cProfile to profile a django app while running on gunicorn

How can I profile a Django application while running on gunicorn using python cProfile.

I can profile in development mode: python -m cProfile -o sample.profile manage.py runserver

But what should I do when it is running in production server using gunicorn?

like image 246
Ramin Mir. Avatar asked Jan 22 '15 11:01

Ramin Mir.


1 Answers

You can run it this way using gunicorn.

$ DJANGO_SETTINGS_MODULE=myapp.settings python -m cProfile -o output_file ../env/bin/gunicorn --workers=8 --bind 127.0.0.1:8000 myapp.wsgi:application 
like image 193
Anonymous Avatar answered Sep 23 '22 03:09

Anonymous