0

Web アプリケーションのプロファイリングを行っていますが、レイテンシーがかなり悪いです。最初のページの読み込みが解決するまでに 200 ミリ秒から 1 秒以上かかる場合があることを確認しました。後続のリクエストは高速になる可能性がありますが、それでも約 300 ミリ秒遅くなります。

Google Chrome レイテンシ

私のスタックは、Rails 4、Ruby 2.0、Unicorn、Apache2、Postgres、Redis、Sidekiq (redis を使用) で構成されています。

関連する可能性のある次の情報を読みました。共有 redis ソケットを再起動するにはどうすればよいですか? これが遅延の原因になる可能性はありますか?

  # if preload_app is true, then you may also want to check and
  # restart any other shared sockets/descriptors such as Memcached,
  # and Redis.  TokyoCabinet file handles are safe to reuse
  # between any number of forked children (assuming your kernel
  # correctly implements pread()/pwrite() system calls)

アパッチのデフォルト:

https://gist.github.com/fogonthedowns/6588751

私の Unicorn.rb ファイルは次のようになります。

worker_processes 2
preload_app true
timeout 30
listen 5000

after_fork do |server, worker|
  ActiveRecord::Base.establish_connection
end

production.rb:

MyApp::Application.configure do
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = true
  config.assets.js_compressor = :uglifier
  config.assets.compile = true
  config.assets.digest = true
  config.assets.precompile += %w( tag.js )
  config.action_mailer.default_url_options = { host: "foo.com" }
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: "foo.com",
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: "no-reply@foo.com",
    password: "foooo"
  }

  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
end

このような遅延の原因は何でしょうか?

生産ログ

  Rendered home/index.html.haml within layouts/application (26.8ms)
Completed 200 OK in 31ms (Views: 29.3ms | ActiveRecord: 1.4ms)
Started GET "/assets/google_button.jpg" for 24.53.176.189 at 2013-09-18 04:19:36 +0000
Started GET "/tags/" for 24.53.176.189 at 2013-09-18 04:19:38 +0000
Processing by TagsController#index as HTML
  Rendered tags/index.html.haml within layouts/application (12.1ms)
Completed 200 OK in 20ms (Views: 16.9ms | ActiveRecord: 1.8ms)
Started GET "/assets/google_button.jpg" for 24.53.176.189 at 2013-09-18 04:19:38 +0000
Started GET "/jason-wade-for-mayor" for 24.53.176.189 at 2013-09-18 04:19:39 +0000
Processing by CommitteesController#show as HTML
  Parameters: {"id"=>"jason-wade-for-mayor"}
  Rendered committees/show.html.haml within layouts/application (35.2ms)
Completed 200 OK in 49ms (Views: 41.8ms | ActiveRecord: 1.8ms)
Started GET "/assets/committee-b8c8544f44424bd9e0234cd1a1fcd796.js" for 24.53.176.189 at 2013-09-18 04:19:40 +0000
Started GET "/assets/google_button.jpg" for 24.53.176.189 at 2013-09-18 04:19:40 +0000
Started GET "/jason-wade-for-mayor" for 24.53.176.189 at 2013-09-18 04:19:54 +0000
Processing by CommitteesController#show as HTML
  Parameters: {"id"=>"jason-wade-for-mayor"}
Redirected to http://redmeetsblue.us/
Filter chain halted as :beta_test rendered or redirected
Completed 302 Found in 25ms (ActiveRecord: 0.0ms)
Started GET "/" for 24.53.176.189 at 2013-09-18 04:19:55 +0000
Processing by HomeController#index as HTML
  Rendered home/index.html.haml within layouts/application (4.6ms)
Completed 200 OK in 8ms (Views: 7.4ms | ActiveRecord: 0.0ms)
Started GET "/assets/google_button.jpg" for 24.53.176.189 at 2013-09-18 04:19:57 +0000
Started GET "/assets/favicon.ico" for 24.53.176.189 at 2013-09-18 04:19:58 +0000
Started GET "/jason-wade-for-mayor" for 24.53.176.189 at 2013-09-18 04:20:10 +0000
Processing by CommitteesController#show as HTML
  Parameters: {"id"=>"jason-wade-for-mayor"}
Redirected to http://redmeetsblue.us/
Filter chain halted as :beta_test rendered or redirected
Completed 302 Found in 2ms (ActiveRecord: 0.0ms)
Started GET "/" for 24.53.176.189 at 2013-09-18 04:20:10 +0000
Processing by HomeController#index as HTML
  Rendered home/index.html.haml within layouts/application (5.3ms)
Completed 200 OK in 9ms (Views: 8.5ms | ActiveRecord: 0.0ms)
Started GET "/jason-wade-for-mayor/contributions/new" for 24.53.176.189 at 2013-09-18 04:22:15 +0000
Processing by ContributionsController#new as HTML
  Parameters: {"committee_id"=>"jason-wade-for-mayor"}
  Rendered contributions/new.html.haml within layouts/application (6.4ms)
Completed 200 OK in 16ms (Views: 10.5ms | ActiveRecord: 1.8ms)
Started GET "/assets/google_button.jpg" for 24.53.176.189 at 2013-09-18 04:22:15 +0000
Started GET "/tags/" for 24.53.176.189 at 2013-09-18 04:22:18 +0000
Processing by TagsController#index as HTML
  Rendered tags/index.html.haml within layouts/application (28.2ms)
Completed 200 OK in 153ms (Views: 36.6ms | ActiveRecord: 4.2ms)
Started GET "/assets/google_button.jpg" for 24.53.176.189 at 2013-09-18 04:22:18 +0000
Started GET "/" for 24.53.176.189 at 2013-09-18 04:22:22 +0000
Processing by HomeController#index as HTML
  Rendered home/index.html.haml within layouts/application (11.1ms)
Completed 200 OK in 16ms (Views: 13.8ms | ActiveRecord: 1.6ms)
Started GET "/assets/google_button.jpg" for 24.53.176.189 at 2013-09-18 04:22:22 +0000
Started GET "/" for 24.7.86.40 at 2013-09-18 04:23:04 +0000
Processing by HomeController#index as HTML
  Rendered home/index.html.haml within layouts/application (8.5ms)
Completed 200 OK in 15ms (Views: 13.9ms | ActiveRecord: 0.0ms)
Started GET "/assets/google_button.jpg" for 24.7.86.40 at 2013-09-18 04:23:04 +0000
Started GET "/assets/favicon.ico" for 24.7.86.40 at 2013-09-18 04:23:05 +0000
4

0 に答える 0