dannymcc
dannymcc

Reputation: 3814

Rails applications take a while to load after no use

I have a number of Rails 3.1 applications running on a local server, remote dedicated server and also on Heroku. Regardless of the applications role they always take quite some time (10 seconds?) to load the first time they are visited.

This delay also happens if an application hasn't been used for around 10 minutes.

I am trying to work out if this is a setting/configuration issue with the servers (and Heroku) or if it's something I can adjust in the Rails applications.

On our main dedicated server I am running the following versions of Rails and Ruby:

Rails 3.1.3

ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.02

Any advice would be appreciated!

(If this question is better suited on ServerFault then let me know!)

Upvotes: 1

Views: 93

Answers (1)

Thilo
Thilo

Reputation: 17735

That's usually the symptom when all active server processes are terminated by the web server in order to conserve resources.

Change the server configuration to keep at least one instance of your app loaded at all time. With mod_rails, for example, settings like passenger_min_instances and passenger_pool_idle_time give you very granular control over this (EDIT: nginx version - Apache version here).

If that is not an option, alternatively you can send a regular HTTP request to your homepage to keep the server process alive, by running a script or using one of the many server monitoring tools like Pingdom, Alertra etc.

Upvotes: 3

Related Questions