Tweak Nginx/Passenger on AWS t1.micro instance

If you’re running Nginx/Passenger and hosting your rails apps on an AWS t1.micro instance, you’d probably have come across this issue of the extremely long load time when passenger spawns up for the very first time.

You’d also probably noticed the same problem when you leave your site idle for a while and only access it a couple of minutes later.

This is because Passenger spins down if idle by default.

In order to keep things up as long as possible and avoid the long loadup, try adding the following into your nginx.conf, insider of the http directive.

passenger_pool_idle_time 1000l
passenger_spawn_method smart;
rails_framework_spawner_idle_time 0;
rails_app_spawner_idle_time 0;
passenger_max_requests 5000;