姜戈。业务逻辑瓶颈。
有没有什么聪明的方法可以找到业务逻辑中的瓶颈。例如,我们有一个应用程序,它有一个在大项目中执行 HttpResponse('1') 的视图。我们确信中间件中不存在 SQL 查询。但是 HttpResponse 工作速度非常慢(在clear django项目上是50 rps vs 200 rps)。
- 可能是什么原因?
- 这种情况下如何找到瓶颈呢?
- 我们还知道,在 Clear 项目中,每个请求的对象使用的内存不到 1 Mb,而在我们的项目中,则超过 2 Mb。如何找到这些对象?
Is there any smart way to find bottlenecks in business logic. For example, we have application, that have one view that doing HttpResponse('1') in big project. We are sure, that no SQL queries in middlewares exists. But HttpResponse working really slow(50 rps vs 200 rps on clear django project).
- What reasons can be?
- How to find bottlenecks in this case?
- Also we know, that in clear project less than 1 Mb of memory used for objects on each request, and in our project - more than 2Mb. How to find these objects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
调试工具栏运行良好,但我也喜欢运行 django-devserver。有时它可以为您提供超出您处理能力的信息。
这是我打开的模块,启动后点击管理页面:
The debug toolbar works well, but I also like running django-devserver. It can give you more information than you can process sometimes.
This is what modules I have turned on, and one hit to the admin page after start:
你使用 django 调试工具栏吗?您可以找到使用它运行的查询,无论是否是中间件。
您如何监控视图的性能?
大项目中的用户是否比新项目中的用户多多?
Do you use the django debug toolbar ? You could find what queries are run with it, middleware or not.
How do you monitor the performance of the view ?
Are there much more users in the big project than in the fresh one ?
我猜你的瓶颈不在你或 django 代码中。您使用什么网络服务器?工作进程处理了多少请求?
如果您使用 mod_wsgi,请确保有足够的工作进程并且最大请求数很高。
当然,请确保未设置settings.DEBUG。
Apache 日志可以包含以微秒为单位的请求处理时间:http://httpd.apache。 org/docs/current/mod/mod_log_config.html 检查 %D
检查你的中间件解释器在你的 +django 代码中的长度。
I guess your bottle neck is not in your or the django code. What webserver do you use, and how many requests are handled by the worker processes?
If you use mod_wsgi be sure to have enough worker processes and that maximum-requests is high.
And of course be sure that settings.DEBUG is not set.
Apache logs can include the request process time in microseconds: http://httpd.apache.org/docs/current/mod/mod_log_config.html check for %D
Check in your middleware how long the interpreter is inside your+django code.
您可以尝试 New Relic,看看它是否有助于缩小问题范围。
好东西那是你吗可以在无法使用 Django 调试工具栏的生产应用程序上使用它。
You could try New Relic and see if it helpful in narrowing down problem area.
Good thing is that you can use it on a production application where Django debug toolbar you cant.