Lennart Koopmann
Lennart Koopmann

Reputation: 21049

My passenger powered Rails app sometimes needs a long time to load

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. ;)

Upvotes: 6

Views: 1492

Answers (4)

stcorbett
stcorbett

Reputation: 613

@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

Upvotes: 0

danbee
danbee

Reputation: 506

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.

Upvotes: 1

Gabe Hollombe
Gabe Hollombe

Reputation: 8067

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.

Upvotes: 1

Jimmy Stenke
Jimmy Stenke

Reputation: 11220

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.

Upvotes: 10

Related Questions