Posts [ 1 to 20 of 24 ]

Topic: First page viewed is slow

We have an RoR app, and it runs fine. It is a production application. We have dual quad-core Pentium servers with 16GB of ram. One of the slowest pages is the first one you see. All it is is a login page, but it takes 5-6 seconds to load.

Can anyone explain this?

Does Rails normally load a lot of stuff when a user first hits the server?

Re: First page viewed is slow

Re: First page viewed is slow

I am using Passenger and the initial app page load is fairly slow 4-6 seconds. Once it loads initially the app runs fine. This is on a very lightly loaded server and the app is only used by one or two users at a time. (But the initial page load delay is still annoying)

I have set the life time to 4 hours or so so once it starts it stays running and loads very quickly.

I know with fastcgi I used before you could start cgi servers when Apache started so initial load was never a problem. Is there a way to do something similar with Passenger (mod_rails)?

Re: First page viewed is slow

Does anyone have any experience improving the speed of the rails process startup time (just loading script/console)? I see significant disparities between the startup times of some of our applications, and would love to find out exactly what is slowing the process down.

Re: First page viewed is slow

I'm having this same problem - excruciatingly slow loading times on the first page. I'm using passenger on DreamHost. Seems like there's three solutions:

1. Adjust the PassengerPoolIdleTime so that the application stays running. (I don't have access to this setting since I'm not on a private server.)

2. Cache the public pages so the application essentially doesn't even need to run at all. (I can't do this cause I have a lot of dynamic content (stock tickers, upcoming events, etc.) on those pages.)

3. Set up a cron job to visit the page at regular interval in order to keep the server fresh (like rogerdpack suggests).

I think a cron job would work for me, but I'm very new to Unix and having some trouble getting it set up / knowing how to check if it's working properly.

I understand that the cron job will need to be set up on the server eventually, but right now I'm just trying to make it work on my computer. Basically, I'd like to have my computer visit the site every five minutes.

Re: First page viewed is slow

I figured this out. Here's how to set up a cronjob on a shared DreamHost server.

1. connect to the server via SSH2. type: crontab -e (this will allow you to edit your cron jobs using the default editor (vim))3. type: i (this will toggle you into "insert" mode (you'll see "- insert -" appear on the bottom of the screen) so that you can insert text into the file)4. paste this line of code into the crontab file: 0,5,10,15,20,25,30,35,40,45,50,55 * * * * wget http://your-domain.com/5. hit the escape key (this will take you out of "insert" mode and return you to "command" mode)6. type: :wq (that means write and quit)7. click enter and you're done.

This is super easy and it works great. It's much better than going through the tedium and limitations of page caching. (Also, I emailed DH to check it this is violation of their policy on running background processes. They said it's cool.)

Re: First page viewed is slow

Re: First page viewed is slow

I did the wget method for a couple days and failed to remember that wget actually retrieves the page, so my home directory was filled with a couple thousand index.html pages. I changed my cron to "curl -s http://www.domain.com > /dev/null" to "ping" the domain if you will, although you could "> /dev/null" with wget as well and avoid the buildup of pages.

Re: First page viewed is slow

I wanted to attempt to revive this thread instead of posting a new topic. I am running a rails 2.3.8 app (Apache+Passenger) on a gig VPS with one or two users. I have noticed that after the app is unaccessed for awhile, the time to get to the login page is 35+ seconds. I viewed the production.log while this was happening and discovered that the login page was rendered in sub-second time, but the page was not received by the client until much later. Where is the bottleneck? In Apache, Passenger, the VPS? Any ideas/advice?

Re: First page viewed is slow

I believe this is Passenger at work. Take a look at the options for passenger configuration and I think you will find that if there is no action for a configurable time the active 'thread' will be deleted and when a new request comes in the whole works will have to be reloaded.

Re: First page viewed is slow

Thanks Norm for you reply. A clarification though - would Passenger be suspect even though the production log says the login page was rendered in sub-second time. I have watched the log while this is taking place and the login page is said to be rendered, but I don't get an html page on the client until 35+ seconds later (I used curl to request the page to eliminate any browser issues).

Re: First page viewed is slow

I do not know. I know it takes a while for the app to crank up under passenger but that depends on system speed etc. Can you run the same basic environment using passenger on your development system locally to eliminate external influences? I have an old (real old) system on my local net that I use just to test the setup under passenger etc. as close as it can be to my deployed system so I can isolate issues like you mention.