Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 python cProfile 在 gunicorn 上运行时分析 Django 应用程序。
我可以在开发模式下进行分析: python -m cProfile -o sample.profile manage.py runserver
python -m cProfile -o sample.profile manage.py runserver
但是当它使用 gunicorn 在生产服务器中运行时我该怎么办?
您可以使用 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