Heroku上的Rails应用随机缓慢的Rack :: MethodOverride#调用 [英] Random slow Rack::MethodOverride#call on rails app on Heroku

查看:108
本文介绍了Heroku上的Rails应用随机缓慢的Rack :: MethodOverride#调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:


  • Ruby:2.1.2

  • Rails:4.1.4

  • Heroku




在Heroku上托管的应用程序中,有时候这些请求需要很长时间才能执行。它只是1倍或更少,但我们无法弄清楚它发生了什么。



我们安装了newrelic代理,它说不是请求排队,它是事务本身需要所有的时间来执行。



然而,事务跟踪显示了这一点:





(同样的请求大部分时间只需要100ms执行)



据我所知,时间在我们的控制器被调用之前被消耗。它在

  Rack :: MethodOverride#call 


此外,大部分时间(甚至总是,我们不是当然),这发生在移动设备发送的POST请求上。这可能与缓慢的连接有关吗? (尽管POST有效载荷非常小)。



有没有人遇到过这种情况?任何意见,如何继续探索这个问题表示赞赏。



预先感谢!

解决方案

由于Ruby代理开始在3.9.0.229版本中测试中间件,所以我们看到一些用户出现了这个问题。较长定时的一个可能原因是Rack :: MethodOverride需要检查POST上的请求正文,以确定POST参数是否包含方法覆盖。它调用 Rack :: Request#POST ,最终触发一个请阅读读入整个请求正文



这可能是您看到在此中间件中花费的时间超过预期的原因。更深入地了解POST机构与中间件所花费的时间之间的关系可能是一个富有成效的调查途径。


Environment:

  • Ruby: 2.1.2

  • Rails: 4.1.4

  • Heroku

In our rails app hosted on Heroku, there are times that requests take a long time to execute. It is just 1% of times or less, but we cannot figure out what it is happening.

We have newrelic agent installed and it says that it is not request-queuing, it is the transaction itself who takes all that time to execute.

However, transaction trace shows this:

(this same request most of the times takes only 100ms to be executed)

As far as I can tell, the time is being consumed before our controller gets invoked. It is consumed on

Rack::MethodOverride#call

and that is what we cannot understand.

Also, most of the times (or even always, we are not sure) this happens on POST requests that are sent by mobile devices. Could this have something to do with a slow connection? (although POST-payload is very tiny).

Has anyone experienced this? Any advice on how to keep exploring this issue is appreciated.

Thanks in advance!

解决方案

Since the Ruby agent began to instrument middleware in version 3.9.0.229, we've seen this question arise for some users. One possible cause of the longer timings is that Rack::MethodOverride needs to examine the request body on POST in order to determine whether the POST parameters contain a method override. It calls Rack::Request#POST, which ends up triggering a read that reads in the entire request body.

This may be why you see that more time than expected is being spent in this middleware. Looking more deeply into how the POST body relates to the time spent in the middleware might be a fruitful avenue for investigation.

这篇关于Heroku上的Rails应用随机缓慢的Rack :: MethodOverride#调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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