views:

400

answers:

5

I use Apache + Passenger to host some Rails applications. Something seems to go in a sleep mode when there is no request for a longer time. It then takes 10-20 seconds for the site to load. Feels like there is something that has to wake up when there have been no requests for a longer time.

How can I fix that? I have enough RAM so it should be no problem if whatever goes to sleep just stays awake. ;)

+6  A: 

Take a look at the PassengerPoolIdleTime parameter for Passenger. It states the maximum number of seconds an application instance can be idle before it shuts down to conserve memory.

The default is 300, but you could try to set a higher number and see if that helps.

Jimmy Stenke
A: 

Also, if you're on a shared host and can't change that setting, you could always write a cron script to hit your site once every x seconds (where x is slightly less than PassengerPoolIdleTime), and update your analytics package to ignore requests from the IP address of the box that's doing the polling.

Gabe Hollombe
A: 

Where is the PassengerPoolIdleTime value actually set? What file do I need to change?

A: 

The passenger documentation recommends setting the PassengerPoolIdleTime to 0 on non-shared hosts that are running only a few Rails apps. That should prevent it from getting unloaded unless it's absolutely necessary.

danbee
A: 

@x0ne, you can set PoolIdleTime (pool_idle_time in nginx) in the global server configuration. In my installation of Nginx that's /opt/nginx/conf/nginx.conf.

Here's the part of passenger's documentation that covers PoolIdleTime: http://www.modrails.com/documentation/Users%20guide.html#PassengerPoolIdleTime

stcorbett