Profiling on a real Django server?

I have never done code coverage in Python, but I'm looking for something like GCC gcov , which tells me how many times each line is executed, or Apple Shark, which gives a hierarchical breakdown of how long each function takes.

My problem is that I have a live server that is experiencing high load, and I can’t tell from the logs what causes it. I would like to attach something to a Django instance to control which lines are the hottest and / or which functions take the longest time.

This is something like, but not quite, code coverage. I would like to introduce it on a server running live, preferably without changing too much.

Ideas?

+6
source share
3 answers
+2
source

Django-live-profiler is a Django application that allows you to profile a running application with statprof and visualize the results.

+3
source

I use this template: monitor threads write stop files to the log file every 0.3 seconds. After a few hours, I see where the translator spends the most time. This does not slow down my server:

Python Server Real-Time Profiling

+1
source

Source: https://habr.com/ru/post/902001/


All Articles