My passenger powered Rails app sometimes needs a l

2019-04-07 15:43发布

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

4条回答
看我几分像从前
2楼-- · 2019-04-07 16:21

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.

查看更多
Emotional °昔
3楼-- · 2019-04-07 16:22

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.

查看更多
狗以群分
4楼-- · 2019-04-07 16:22

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.

查看更多
男人必须洒脱
5楼-- · 2019-04-07 16:25

@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

查看更多
登录 后发表回答