ruby-on-rails-3passengerphusion

Passenger slow at startup and after some seconds of idle time


I'm currently facing a problem with Passenger (4.0.18) in combination with a simple Rails 4.0.0 application. Problem is, that after starting apache, the first request is extremely slow ( usually 30.x seconds). The following requests are really fast but if the app is idle for 20+ seconds, the same happens again.

Now, this problem in general has already been discussed here several times, and of course I already tweaked the apache config:

 PassengerSpawnMethod smart
 PassengerPoolIdleTime 1000
 RailsAppSpawnerIdleTime 0
 PassengerMaxRequests 1000
 PassengerMaxPreloaderIdleTime 0

But this did not help at all. If I check passenger-status it tells me this:

 Version : 4.0.18
 Date    : 2014-01-31 13:06:59 +0100
 Instance: 20601
 ----------- General information -----------
 Max pool size : 6
 Processes     : 1
 Requests in top-level queue : 0

Funny thing is, that when I do a 'watch' on passenger-status while doing a request, nothing really changes here. (Especially not the Requests line).

I already fiddled around with tcpdump, all requests arive in time, so there's no network delay visible. I also enabled apache extended logging ( with added request times ) - this is quite interesting, let's say a normal request takes around 200msec, then one of these slow requests takes exactly 30.2 seconds.

Any idea what this could cause?

Apache is a 2.2.15. (redhat version, with backported security patches...:) )

Thanks in advance, Björn


Solution

  • Use PassengerPreStart: http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerPreStart. That documentation section also explains why you experience the behavior that you observe.