为什么ActionDispatch :: Routing :: RouteSet需要这么长时间 [英] Why ActionDispatch::Routing::RouteSet takes so long

查看:90
本文介绍了为什么ActionDispatch :: Routing :: RouteSet需要这么长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Rails 4.2.1之上使用Grape来为我们的应用程序提供API.

I am using Grape on top of Rails 4.2.1 to provide API for our application.

但是当我今天检查Newrelic的性能时,我发现RackApp Proc#callGrape API::Root#call占用了大量时间. (请参见屏幕截图)

But when I check Newrelic for performance today I found that RackApp Proc#call and Grape API::Root#call are taking up large amount of time. (See the screenshot)

然后我尝试使用rack_timer记录中间件中消耗的时间,发现ActionDispatch::Routing::RouteSet占用了大部分时间:

Then I tried to log the time consumed in middleware with rack_timer and found that ActionDispatch::Routing::RouteSet is taking up most of the time:

Rack Timer (Application Action) -- ActionDispatch::Routing::RouteSet: 67.12579727172852 ms
Rack Timer (Application Action) -- ActionDispatch::Routing::RouteSet: 101.51457786560059 ms
Rack Timer (Application Action) -- ActionDispatch::Routing::RouteSet: 84.18059349060059 ms
Rack Timer (Application Action) -- ActionDispatch::Routing::RouteSet: 1236.2565994262695 ms
Rack Timer (Application Action) -- ActionDispatch::Routing::RouteSet: 8.124351501464844 ms
Rack Timer (Application Action) -- ActionDispatch::Routing::RouteSet: 55.65309524536133 ms

ActionDispatch::Routing::RouteSet中,有些情况甚至需要500毫秒-1000毫秒.我如何找到这个问题?我怎么知道我在Rails路线中做错了什么?

There are even cases that take 500ms - 1000ms in ActionDispatch::Routing::RouteSet. How could I track down this problem and how could I know what have I done wrong in Rails routes?

非常感谢您的帮助.

推荐答案

对我来说,事实证明,Newrelic红宝石代理不适用于我用来构建API端点的gem.rocket_pants.

For me, it turns out that Newrelic ruby agent does't work with rocket_pants, the gem I use to build API endpoints.

有一个第三方gem'rocket_pants-rpm'可以解决此问题,但是原始版本从3.9+的newrelic_rpm版本开始停止工作,要解决此问题,请尝试在

There is a third party gem 'rocket_pants-rpm' to solve this issue, but the original one stop working from newrelic_rpm version 3.9+, to fix the issue, try using the forked version at https://github.com/SpartaSales/rocket_pants-rpm

这是添加此宝石后newrelic报告查找我的方式.

This is how newrelic report looks for me after adding this gem.

新请求时间百分比

这篇关于为什么ActionDispatch :: Routing :: RouteSet需要这么长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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