I have a web app hosted in a cloud environment which can be expanded to multiple web-nodes to serve higher load.
我有一个托管在云环境中的web应用程序,它可以扩展到多个web节点以提供更高的负载。
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?
当我们收到越来越多的HTTP请求(资产被远程存储)时,我需要做的就是捕捉这种情况。我怎么做呢?
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..
我从这个角度看到的问题是,如果我们有比mongrel集群能够处理的更多的请求,那么队列将会增长。在我们的Rails应用中,我们只能在mongrel收到平衡器的请求后才能计数。
Any recommendations?
你有什么推荐吗?
2 个解决方案
#1
3
I would start with an around_filter
maybe something like:
我先用一个around_filter,比如:
around_filter :time_it
private
def time_it
now = DateTime.now
yield # this is where the request gets made.
time_span = DateTime.now - now
# convert to double for better accuracy.
# (i.e. 3.5 => 4 so you might not want to
# work with integers here.
if time_span * 86400.0 > 4.0
logger.debug "something is taking a little longer then expected here!"
end
end
Use this as a starting point. Hope that helps.
以此为起点。希望有帮助。
Edit: put this code in the ApplicationController so it can be used by every Controller.
编辑:把这个代码放在ApplicationController中,这样每个控制器都可以使用它。
#2
1
In addition to @DJTripleThreat, you should have a look at NewRelic RPM to get more insight to your code's performance.
除了@DJTripleThreat之外,您还应该查看NewRelic RPM以了解代码的性能。
#1
3
I would start with an around_filter
maybe something like:
我先用一个around_filter,比如:
around_filter :time_it
private
def time_it
now = DateTime.now
yield # this is where the request gets made.
time_span = DateTime.now - now
# convert to double for better accuracy.
# (i.e. 3.5 => 4 so you might not want to
# work with integers here.
if time_span * 86400.0 > 4.0
logger.debug "something is taking a little longer then expected here!"
end
end
Use this as a starting point. Hope that helps.
以此为起点。希望有帮助。
Edit: put this code in the ApplicationController so it can be used by every Controller.
编辑:把这个代码放在ApplicationController中,这样每个控制器都可以使用它。
#2
1
In addition to @DJTripleThreat, you should have a look at NewRelic RPM to get more insight to your code's performance.
除了@DJTripleThreat之外,您还应该查看NewRelic RPM以了解代码的性能。