Search code examples
ruby-on-railsiisjrubypumajrubyonrails

Prevent jRuby on Rails app with Puma/IIS from falling asleep after a set amount of time


We are running an application on Windows Server 2012, using jRuby 1.7.20.1, puma, and IIS 8+.

The start up time on jRuby is a little long which is fine, because the app runs really fast after that as long as it is receiving requests. The issue is that if there is an extended amount of time where the app is not receiving requests, jRuby seems to fall asleep, and the next request that comes in has to go through the entire startup process again.

I've tried adding a .jrubyrc to the root of the app for jRuby to pick up on with the active thread pool min set to 1 (0 is default). But that did not seem to do anything.

The last-ditch solution we are considering is adding a script that just sends a small request on an interval to prevent it, but that seems jenky obviously, Im convinced there is some way to configure jRuby to keep it active.


Solution

  • This actually turned out to be a setting that needed to be changed in IIS for the ApplicationPool running our app.

    Under AppPool > advanced settings > idle timeout

    We had to change the setting from terminate to suspend. Now it is working fine.