9

如何使用 python cProfile 在 gunicorn 上运行时分析 Django 应用程序。

我可以在开发模式下进行分析: python -m cProfile -o sample.profile manage.py runserver

但是当它使用 gunicorn 在生产服务器中运行时我该怎么办?

4

1 回答 1

3

您可以使用 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 
于 2017-02-16T09:42:24.363 回答