简体   繁体   English

在实时Django服务器上进行分析?

[英]Profiling on live Django server?

I've never done code coverage in Python, but I'm looking for something like GCC 's gcov , which tells me how many times each line executes, or Apple's Shark which gives a hierarchial breakdown of how long each function is taking. 我从未在Python中完成代码覆盖,但我正在寻找类似GCCgcov ,它告诉我每行执行多少次,或者Apple的Shark,它给出了每个函数花费多长时间的层次细分。

My problem is that I have a live server which is experiencing high load, and I can't tell from the logs what's causing it. 我的问题是我有一个正在经历高负载的实时服务器,我无法从日志中分辨出导致它的原因。 I would like to attach something to my Django instance to monitor which lines are the hottest and/or which functions are taking the longest time. 我想在我的Django实例上附加一些东西,以监控哪些线路最热和/或哪些功能花费的时间最长。

This is something like, but not exactly, code coverage. 这类似于但不完全是代码覆盖。 I would like to introduce it to a live running server, preferably without modifying too much. 我想将它介绍给一个实时运行的服务器,最好不要修改太多。

Ideas? 想法?

Django-live-profiler是一个插入式Django应用程序,它允许您使用statprof配置正在运行的应用程序并可视化结果。

cProfile + RunSnakeRun: http ://www.vrplumber.com/programming/runsnakerun/

I use this pattern: A monitor threads writes stacktraces to a log file every 0.3 seconds. 我使用这种模式:监视器线程每0.3秒将堆栈跟踪写入日志文件。 After some hours I can see where the interpreter spends the most time. 几个小时后,我可以看到口译员花费最多的时间。 It does not slow down the my server: 它不会减慢我的服务器速度:

Live Profiling of Python Server Python服务器的实时概要分析

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM