Profiling on live Django server?

2024/9/19 21:29:18

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?

Answer

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

https://en.xdnf.cn/q/72750.html

Related Q&A

Inset axes anchored to specific points in data coordinates?

Id like to be able to overlay multiple inset axes on top of a set of parent axes, something like this:Ideally, Id like the anchor point of each set of inset axes to be fixed in data coordinates, but fo…

No module named folium.plugins, Python 3.6

I am trying to import folium into a Jupyter notebook Im working on and I cannot seem to solve the import issues with the Folium library. Has anyone else solved this problem?After encountering an error…

How you enable CBC to return best solution when timelimit? (Pyomo)

I am trying to use CBC(v2.10.3) on Pyomo to solve for a integer linear problem.When executing the solver, I am currently setting a timelimit of 600s.opt = SolverFactory ("cbc")opt.options[sec…

SSL cert issue with Python Requests

Im making a request to a site which requires SSL cert to access. When I tried to access the URL, I get SSL Certificate errorimport requests proxies = {"https":"https://user:pwd@host:port…

MatplotLib get all annotation by axes

im doing a project with Python and Tkinter. I can plot an array of data and i also implemented a function to add annotation on plot when i click with the mouse, but now i need a list of all annotation…

Using Pandas to applymap with access to index/column?

Whats the most effective way to solve the following pandas problem? Heres a simplified example with some data in a data frame: import pandas as pd import numpy as np df = pd.DataFrame(np.random.randin…

Multiple URL segment in Flask and other Python frameowrks

Im building an application in both Bottle and Flask to see which I am more comfortable with as Django is too much batteries included.I have read through the routing documentation of both, which is very…

installing python modules that require gcc on shared hosting with no gcc or root access

Im using Hostgator shared as a production environment and I had a problem installing some python modules, after using:pip install MySQL-pythonpip install pillowresults in:unable to execute gcc: Permiss…

Using libclang to parse in C++ in Python

After some research and a few questions, I ended up exploring libclang library in order to parse C++ source files in Python.Given a C++ source int fac(int n) {return (n>1) ? n∗fac(n−1) : 1; }for …

Python one class per module and packages

Im trying to structure my app in Python. Coming back from C#/Java background, I like the approach of one class per file. Id like my project tree to look like this:[Service][Database]DbClass1.pyDbClass2…