Rails:如何记录所有执行时间超过 4 秒的请求?
我有一个托管在云环境中的 Web 应用程序,可以扩展到多个 Web 节点以服务更高的负载。
我需要做的是当我们收到越来越多的HTTP请求(资产被远程存储)时捕获这种情况。我怎样才能做到这一点?
从这个角度来看,我看到的问题是,如果我们的请求多于混合集群可以处理的数量,那么队列将会增长。在我们的 Rails 应用程序中,我们只能在 mongrel 收到平衡器的请求后才进行计数。
有什么建议吗?
I have a web app hosted in a cloud environment which can be expanded to multiple web-nodes to serve higher load.
What I need to do is to catch this situation when we get more and more HTTP requests (assets are stored remotely). How can I do that?
The problem I see from this point of view is that if we have more requests than mongrel cluster can handle then the queue will grow. And in our Rails app we can only count only after mongrel will receive the request from balancer..
Any recommendations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会从一个
around_filter
开始,也许类似:使用它作为起点。希望有帮助。
编辑:将此代码放入ApplicationController中,以便每个控制器都可以使用它。
I would start with an
around_filter
maybe something like:Use this as a starting point. Hope that helps.
Edit: put this code in the ApplicationController so it can be used by every Controller.
除了 @DJTripleThreat 之外,您还应该看看 NewRelic RPM,以更深入地了解代码的性能。
In addition to @DJTripleThreat, you should have a look at NewRelic RPM to get more insight to your code's performance.