Topic: Response of first request very slow

Why is it that the first request of a rails application view is so slow...

After that (the same amount but different sql queries) things go alot smoother.

It looks like the app needs some time to initialize.

Is there a way to do it faster ?

Re: Response of first request very slow

I could be wrong but I thnk this has something to do with starting/waking up the server especially after a deployment when the server is shutdown and only re-started on first request.

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Response of first request very slow

where is your app deployed, what mode (dev., prod, or test) is it deployed in, and what server etup are you using?

Re: Response of first request very slow

I

Re: Response of first request very slow

With Apache/Passenger...there is a <PassengerPoolIdleTime> setting that can be adjusted.  You might want to look for something similar in your Nginx/Thin setup.

Re: Response of first request very slow

Did you tried Mongrel server ? Passenger takes time to spawn process during its initial request. But mongrel runs as a daemon and its a less probability to have a delayed initial load time.

Re: Response of first request very slow

I had the same problem. Because my application had not a lot of visitors the application was taken out of memory, so when I went back to the application it took almost 2 minutes to load. I was not able to edit the PassengerPoolIdleTime so I was searching an alternative and I found a tool called wekkars ( http://www.wekkars.com ) that does exactly what I need. It keeps my application alive and fast accessible for my visitors.

Re: Response of first request very slow

I was grateful to have this information that was very meaningful to me.