简体   繁体   中英

Understanding Rails runtime metrics

I'm trying to diagnose a performance issue in Rails 4 and can't figure out what's going on. Here's the timing that I'm seeing on my server:

Completed 200 OK in 2816ms (Views: 644.1ms | ActiveRecord: 162.0ms | Solr: 0.0ms)

I'm (mostly) satisfied with my Views time, and ActiveRecord time, but don't understand why the Completed time (2816ms) is so large.

What does that time represent? And is there any way to decrease that time?

What you're showing is that over 2/3 of your request processing time isn't included in the model/view. What's left? Other code running within your controller and request processing life-cycle.

The best way to profile this is to install the newrelic RPM gem and run the local profiler:

Add the gem to your Gemfile:

gem 'newrelic_rpm'

Enable local profiling in development for config/newrelic.yml:

development:
  <<: *default_settings
  monitor_mode: false
  developer_mode: true

Execute your request 2-3 times to warm up your Rails app and then visit the local newrelic app to view the traces and track down what's happening:

http://localhost:3000/newrelic

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM