【问题标题】:Why would Application#call be slow?为什么 Application#call 会很慢?
【发布时间】:2015-02-17 14:32:45
【问题描述】:

由于某种原因,我的::Application#call 非常慢。在一种情况下,根据 New Relic 的仪器,它使用了 3,840ms

文档只是将此方法描述为:Implements call according to the Rack API. It simply dispatches the request to the underlying middleware stack.

甚至到ActionDispatch::Routing::RouteSet#call都需要5秒钟以上,更不用说我的控制器的方法了。

为什么会这么慢?我可以在哪里尝试进一步深入研究呢?

我的中间件也没有一个看起来特别奇怪:

use Raven::Rack
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007fd836083e08>
use Rack::Runtime
use ActionDispatch::RequestId
use Rails::Rack::Logger
use Rack::Cors
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Callbacks
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::ParamsParser
use Clearance::RackSession
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
use ActionDispatch::Flash
use Rack::SslEnforcer
run CookacademyApi::Application.routes

【问题讨论】:

  • 您检查过 New Relic 上的中间件工具吗?如果对应用程序的调用和对路由的调用之间有一些缓慢的地方,它可能是一个中间件。要查看中间件堆栈中的内容,您可以运行 rake middleware
  • @fivedigit middelware 工具似乎没有向我展示太多:cl.ly/image/1B3P143p2g3K
  • @JoshSmith 你找到解决方案了吗?我也面临同样的问题
  • @JoshSmith 同样的问题在这里,什么?
  • 是的,newrelic 真的没那么有用:(

标签: ruby-on-rails-4 rack


【解决方案1】:

不要过分依赖 NewRelic 指标。我最近遇到了同样的问题,页面 NR 估计大约需要 3 秒才能加载。关闭几个应用程序并重新启动 firefox NR 后显示不到 300 毫秒

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-06
    • 2019-10-02
    • 2010-10-30
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多