rails总体请求时间比视图+活动记录长

时间:2017-02-06 10:33:18

标签: ruby-on-rails

我有这个日志条目:

Completed 200 OK in 519ms (Views: 306.2ms | ActiveRecord: 32.8ms)

如果渲染+活动记录的视图低于整体请求时间,怎么会发生?

这是行动包中保存时间的对象:

=> #<ActiveSupport::Notifications::Event:0x007feeeba29590
 @children=[],
 @duration=742.621,
 @end=2017-02-06 12:23:23 +0200,
 @name="process_action.action_controller",
 @payload=
  {:controller=>"ProjectsController",
   :action=>"update",
   :params=>{"project"=>{"name"=>"Wwww.."}, "client_initiated_at"=>"Mon, 06 Feb 2017 10:23:22 GMT", "controller"=>"projects", "action"=>"update", "id"=>"3"},
   :format=>:js,
   :method=>"PUT",
   :path=>"/workspaces/3",
   :status=>200,
   :view_runtime=>314.45606005598603,
   :db_runtime=>85.04700000000001},
 @time=2017-02-06 12:23:22 +0200,
 @transaction_id="e0dfa141c53a0a641111">

在生产中情况更糟: Completed 200 OK in 3637ms (Views: 56.5ms | ActiveRecord: 79.8ms)

我们在每次请求时都会失去差不多3.5秒,因为还有其他东西...... 知道从哪里开始首次亮相的失败?

1 个答案:

答案 0 :(得分:0)

你应该研究Rack-mini-profiler gem。它制作精良,可以深入了解您的需求。

This is a pretty good tutorial about it