【问题标题】:How can I use python's cProfile to profile a django app while running on gunicorn在 gunicorn 上运行时,如何使用 python 的 cProfile 来分析 django 应用程序
【发布时间】:2015-03-21 04:32:00
【问题描述】:

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

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

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

【问题讨论】:

  • 认为web: args 在工头中工作,但猜猜I'm not ...!
  • 我认为没有什么好的方法可以使用 cProfile 来分析在 gunicorn 下运行的 django 应用程序。你需要弄清楚什么?我发现使用日志系统来跟踪我的视图执行所需的时间是最有用的。
  • 你可以看看这个用于 Django 的分析器:github.com/django-silk/silk 它在内部使用 cProfile。

标签: python django profiler gunicorn cprofile


【解决方案1】:

您可以使用 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 

【讨论】:

    猜你喜欢
    • 2013-03-06
    • 2013-04-29
    • 2019-09-27
    • 1970-01-01
    • 1970-01-01
    • 2017-08-25
    • 2017-04-11
    • 2022-01-15
    • 1970-01-01
    相关资源
    最近更新 更多