0

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

Kleber S.
  • 131
  • 5

2 Answers2

0

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;
0

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 
nulltek
  • 1,251
  • 3
  • 14
  • 22