刚才看了一下生产环境的 middleware,发现有一堆:
Rack::Cache Rack::Lock #ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x000000030c4f88 Rack::Runtime Rack::MethodOverride ActionDispatch::RequestId Rails::Rack::Logger ActionDispatch::ShowExceptions ActionDispatch::DebugExceptions ActionDispatch::RemoteIp Rack::Sendfile ActionDispatch::Callbacks ActiveRecord::ConnectionAdapters::ConnectionManagement ActiveRecord::QueryCache ActionDispatch::Cookies ActionDispatch::Session::CookieStore ActionDispatch::Flash ActionDispatch::ParamsParser Remotipart::Middleware ActionDispatch::Head Rack::ConditionalGet Rack::ETag ActionDispatch::BestStandardsSupport Warden::Manager ClientSideValidations::Middleware::Validators ExceptionNotifier Noie Barista::Server::Proxy NewRelic::Rack::BrowserMonitoring OmniAuth::Strategies::GoogleApps Rack::Pjax Sass::Plugin::Rack
然后一个个看下来没有什么可以去掉的,这么多 middleware 会不会有性能问题? 原理上面来说是每一个请求都有几十个方法嵌套, 不知道多那么多因此带来多少的性能损失,个人预估不会很大,大家谁测试过的,以及看法如何?我的看法是普通应用不要管那么多。。