简体   繁体   English

了解Rails运行时指标

[英]Understanding Rails runtime metrics

I'm trying to diagnose a performance issue in Rails 4 and can't figure out what's going on. 我正在尝试诊断Rails 4中的性能问题,无法弄清楚发生了什么。 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) 在2816ms内完成200 OK(查看: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. 我(大部分)对Views时间和ActiveRecord时间感到满意,但不明白为什么Completed时间(2816ms)这么大。

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. 您显示的是模型/视图中没有超过2/3的请求处理时间。 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: 对此进行分析的最好方法是安装newrelic RPM gem并运行本地分析器:

Add the gem to your Gemfile: 将宝石添加到您的Gemfile中:

gem 'newrelic_rpm'

Enable local profiling in development for config/newrelic.yml: 在开发中为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: 执行2-3次请求以预热Rails应用程序,然后访问本地newrelic应用程序以查看跟踪并跟踪发生的事情:

http://localhost:3000/newrelic

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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