Why does ActionDispatch :: Routing :: RouteSet take so long

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

But when I test Newrelic for performance today, I find that RackApp Proc#call and Grape API::Root#call are time consuming. (See screenshot)

enter image description here

Then I tried to record the time spent on the middleware using rack_timer and found that ActionDispatch::Routing::RouteSet takes 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 

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

Thank you for help.

+8
performance ruby-on-rails ruby-on-rails-4 newrelic grape
source share
1 answer

For me, it turns out that the Newrelic ruby ​​agent doesn't work with rocket_pants, which I use to create API endpoints.

To solve this problem, there is a third-party gem "rocket_pants-rpm", but the original stops working with newrelic_rpm version 3.9+, to fix the problem, try using the branched version at https://github.com/SpartaSales/rocket_pants-rpm

Here's what the new peer-reviewed report looks like after adding this gem.

percentage of request for a new request

0
source share

All Articles