Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 558
Lennart Koopmann Avatar asked Feb 24 '09 13:02

Lennart Koopmann


People also ask

Why is Rails slow?

Memory is the #1 reason why any Ruby application is slow. The 80-20 rule of Rails performance optimization is: 80% of speedup comes from memory optimization, remaining 20% from everything else.

What is app server in Rails?

The app server uses Rack to fire your Rails app. Then your app returns the response back through the app server and the web server to the browser of the user. For example, Apache passes a HTTP request to Puma, then Puma put some process on it before sending it to Rails App(or Sinatra app).

What is web server Ruby on Rails?

Ruby on Rails (simplify as Rails) is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and web pages.


1 Answers

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.

like image 181
Jimmy Stenke Avatar answered Sep 21 '22 02:09

Jimmy Stenke