سؤال

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

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

An easy and secure way to make sure that your server is up and ready for processing request is to make a crone job to curl the website every n minutes (which in my case n = 3).

my crone script is:

 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /bin/bash -l -c 'cd /var/www/example.com && curl -i https://www.example.com/ >> log/curl-www.example.com.log 2>&1'

you can validate the crone task here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top