Django/WSGI - 如何分析部分请求?我的分析工具是针对每个请求的,但在此之前应用程序内存不足 [英] Django / WSGI - How to profile partial request? My profiling tools are per-request but app runs out of memory before then

查看:46
本文介绍了Django/WSGI - 如何分析部分请求?我的分析工具是针对每个请求的,但在此之前应用程序内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何分析我的 python/django 应用程序,该应用程序在占用更多内存 100 秒后因单个请求而崩溃?

How can I profile my python / django application which is crashing on a single request after 100 seconds of hogging more memory?

我在上面看到的只是 wsgi 进程正在缓慢地消耗内存,直到它崩溃.

All I see in top is that the wsgi process is consuming memory slowly until it crashes.

我所知道的唯一分析技术在完整的请求/响应周期中运行,但我无法完成请求.然后呢?

The only profiling techniques I know run on a full request/response cycle but I'm not able to finish a request. What then?

我什至可能会运行开发服务器并尝试在请求中终止它并查看堆栈的位置.

I might even run the dev server and try to kill it mid-request and see where the stack is.

推荐答案

有点繁琐,会有一些开销,但你可以使用 sys.setprofile() 提供一个函数,在进入和退出函数和转储时调用自己调用日志文件的进度,可能同时检查正在使用的内存.

A bit fiddly and will have some overhead, but you could use sys.setprofile() to provide a function to be called on entry and exit from functions and dump progress of calls out to a log file yourself, potentially with check of memory in use at the same time.

http://docs.python.org/dev/library/sys.html#sys.setprofile

也许还可以检查 heapy 作为一种让控制台类型访问您的实时进程以转储内存/对象使用情况的方式.

Also perhaps check out heapy as a way of getting console type access into your live process to dump out memory/object usage.

这篇关于Django/WSGI - 如何分析部分请求?我的分析工具是针对每个请求的,但在此之前应用程序内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆