Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm running nginx 1.0.4 with Passenger 3.0.11 and Rails applications and I've noticed that on every request I made, it takes about 5 seconds to respond for the first request, if I reload it, after the first request completes, it's fast but if I wait for a minute for example, again the new first request takes time.

Is this normal or could be something wrong with my configs?

OS: MacOSX 10.7.3

share|improve this question

2 Answers 2

Longer wait for first passenger request (on low usage site) is normal.

You can prestart instance of passenger to avoid first request wait.

For example:

in http {} part of nginx config

passenger_pre_start http://url_of_your_application/;

in server {} part

passenger_min_instances = 1;
share|improve this answer

Another option you could look at is setting a cron job for every 5 minutes that will wget the site url thus keeping Passenger spun up and ready. I have the same problem in production where if the app is not used for a while accessing it is slow (3-5 sec) the first time while Passenger spins up. Then after that it's very quick.

Here's another way of keeping it alive (add to your crontab:

*/5 * * * * wget http://yoursite.com > /dev/null 2>&1 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.