How can I use python cProfile to profile a django application while working on gunicorn

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

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

But what should I do when it runs on a production server using gunicorn?

+5
source share
1 answer

You can launch it this way using guns.

 $ 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 
+3
source

Source: https://habr.com/ru/post/1211695/


All Articles