Rails 3.2, Ruby 1.9 and Unicorn - The First Request is Very Slow - How to debug? -
i've got large 2.3 rails app running on unicorn. i'm using unicorn, can have 0 downtime deployments. however, i've noticed first request after restart very slow.
first request: completed 304 not modified in 2771.8ms (activerecord: 98.6ms)
second request: completed 304 not modified in 94.4ms (activerecord: 26.9ms)
i have preload_app true
, re-establishing db-connection in after-fork.
i have no idea how explain 2600ms divergence between these 2 values.
does have thoughts? really, looking ways debug issue.
update
here unicorn.log after restart:
i, [2014-05-16t13:46:26.529305 #11637] info -- : executing ["/data/app/current/ey_bundler_binstubs/unicorn", "-e", "staging", "-c", "/data/app/shared/config/custom_unicorn.rb", "-d", "/data/app/current/config.ru", {12=>#<kgio::unixserver:fd 12>}] (in /data/app/releases/20140516184210) i, [2014-05-16t13:46:27.566115 #11637] info -- : inherited addr=/var/run/engineyard/unicorn_afar.sock fd=12 i, [2014-05-16t13:46:27.566551 #11637] info -- : refreshing gem list i, [2014-05-16t13:47:13.036963 #8247] info -- : reaped #<process::status: pid 8681 exit 0> worker=3 i, [2014-05-16t13:47:14.093196 #8247] info -- : reaped #<process::status: pid 8670 exit 0> worker=2 i, [2014-05-16t13:47:14.100269 #12047] info -- : worker=0 ready i, [2014-05-16t13:47:15.105249 #12063] info -- : worker=1 ready i, [2014-05-16t13:47:15.114038 #8247] info -- : reaped #<process::status: pid 8655 exit 0> worker=1 i, [2014-05-16t13:47:15.957970 #8247] info -- : reaped #<process::status: pid 8638 exit 0> worker=0 i, [2014-05-16t13:47:15.958159 #8247] info -- : master complete i, [2014-05-16t13:47:16.087761 #12082] info -- : worker=2 ready i, [2014-05-16t13:47:16.876129 #11637] info -- : master process ready i, [2014-05-16t13:47:17.102994 #12095] info -- : worker=3 ready
and here first request on rails logs:
started "/" 70.xx.xxx.xxx @ 2014-05-16 13:47:51 -0700 processing homecontroller#index html (1.1ms) select ..... <regular controller/activerecord queries> completed 304 not modified in 2724.8ms (activerecord: 98.9ms)
first request rails app slow may relevant.
maybe there dependency loading / running on first page load?
some ideas:
check rails log see if there's funky going on
is happening unicorn or other servers too?
add log statements time stamps sense part of app taking long time
try using ruby prof
Comments
Post a Comment