Profiling on live Django server?

元气小坏坏 提交于 2019-12-21 04:51:33

问题


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.

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.

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?


回答1:


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




回答2:


Django-live-profiler is a drop-in Django app that lets you profile your running application using statprof and visualize the results.




回答3:


I use this pattern: A monitor threads writes stacktraces to a log file every 0.3 seconds. 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



来源:https://stackoverflow.com/questions/8213007/profiling-on-live-django-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!