Optimizing RoR and Passenger

Added by Brandon Dixon about 11 years ago

Last week I started to notice that our company Redmine instance was experiencing a lot of delay and for no apparent reason. At the time I was using a standard mongrel instance and felt that it was time to make the switch to passenger and apache2. I set everything up and I certainly noticed a difference in performance, but it still tends to delay initially when starting up the application or if I don't constantly click around. I took a look on a few sites because my thoughts were that the application itself needed to be loaded and maybe that was causing the delay.

I did some research and saw some people recommending to adjust PassengerPoolIdleTime, so thats what I did (setting it to 0 to always keep the processes open), but I still seem to have some delays. I had installed passneger-2.2.4 and had that all configured in Apache, but when I ran passenger-memory-stats it showed that passeneger-2.1.2 was actually loaded and running. I adjusted my Apache configuration and unfortunately I still have the same delay. I also read about running a cron job that accesses the website every couple minutes so that the processes keep open, but this seems kind of hokey. I am still going to give it a shot and see what occurs (updates to follow).

The server itself never takes on much load. I am running Ubuntu Server 8.04 (LTS), Gems 1.3.1, and Ruby 1.8. At the most there are 3-4 people accessing the system at one time, but that is rare and never lasts for an extended period of time. Has anyone else experienced this issue or have any suggestions?

Replies (10)

RE: Optimizing RoR and Passenger - Added by Jason Sjöbeck about 11 years ago

I am in a very similar place. We're running centOS 5.3, latest stable stock httpd, SSL, mod_ssl, Passenger, Redmine 0.8.3, Rails 1.8.7, and we have it served up as a sub-uri (ie: www.somewhere.net/redmine/) off our main site. Works but sluggish. I see the dev's really prefer it run through weBrick.

I wonder if there is a way to get this baby to really scream?!

We tried 'fastcgi' but it just doesn't seem to like it (throwing all kinds of errors). Has any one got it working with fastcgi.

We love the project, the site, the look, feel, integration with our SVN, and LDAP, and cant wait to get it tuned so that we 2 ssadmin's using it now can release it to the rest of our team.

Any tips & advice & suggestions are most appreciated.

RE: Optimizing RoR and Passenger - Added by Brandon Dixon about 11 years ago

Update: I tried out calling the page with the cron job and had no luck.

I have yet to try things out using the Webbrick method, but I would honestly like to avoid that just because I like everything contained in Apache.

I would love to know what the owners of the Redmine site have setup because there is never any delay when accessing anything. Help up out guys!

RE: Optimizing RoR and Passenger - Added by Eric Davis about 11 years ago

Brandon Dixon wrote:

I did some research and saw some people recommending to adjust PassengerPoolIdleTime, so thats what I did (setting it to 0 to always keep the processes open), but I still seem to have some delays.

I have mine set to 600 or 10 minutes.

I had installed passneger-2.2.4 and had that all configured in Apache, but when I ran passenger-memory-stats it showed that passeneger-2.1.2 was actually loaded and running. I adjusted my Apache configuration and unfortunately I still have the same delay.

Can you check a few things:

  • Did you rerun passenger-install-apache2-module with 2.2.4?
  • Did you restart Apache after installing?
  • Are you running Ruby Enterprise Edition? If so, it uses a separate Ruby gem installation so you might need to check that the latest passenger is installed there.

Jason Sjöbeck wrote:

I see the dev's really prefer it run through weBrick.

Please do not run Redmine or any production web app with Webrick. Webrick is a Ruby development server that is known it stop responding and leak memory if it's run for a long period of time. Running a single mongrel is a lot faster and more stable than Webrick.

We tried 'fastcgi' but it just doesn't seem to like it (throwing all kinds of errors). Has any one got it working with fastcgi.

I don't like fastcgi either but Redmine.org is using fastcgi so it could work.

Eric Davis

RE: Optimizing RoR and Passenger - Added by Jason Sjöbeck about 11 years ago

Eric,
All,

Thanks so much for the very good information. Very much appreciated. We really dig on Redmine, great great web app'.

We continue to use it. We continue to think it is sluggish when changing pages. We are totally fine & accept the fact that it takes 5 seconds to load up the very first time, who cares, one-time only thing upon loading it up, but our work is quite slowed-down by waiting the few seconds each & every time we touch a page or button or comment or change pages. I am not complaining. I am not accusing anything or any one. It might very well be our config'. We require SSL & I'm sure that even that tiny bit of overhead adds to it. To the meat of the matter .......
1. we have only allocated 1gb of RAM to the VM (ie: inside Xen) & we might double that
2. we are using Passenger
3. we are not using Mongrel (I might try this later but only if no luck after a few more tries)
4. we would like to get FastCGI working. (couldn't figure it out first try but will try again soon) If any one else has step-by-step HOWTO for enabling & using FastCGI, that would be most appreciated.
5. totally separately & off the topic of performance, we are just about down integrating SVN & the GUI to manage repositories using either method. (that will be great to have!) I do not believe this has anything to do with performance, but I only mention it here for full disclosure.
6. I had no idea about weBrick, so appreciate the explanation there (Eric) of what that is suggested for.
7. yes, we restart "httpd" after every edit. We have learned over the year that it is most wise to edit ONLY one variable & restart the web daemon & re-try. Lather, rinse, repeat.
8. we have not edited the IDLE variable at all. It sounds like it doesn't really matter (much?) so probably wont touch it.
9. no we are not running Enterprise Edition of anything, let alone Ruby (we are in the mode of "building it" & "not buying it" right now).
10. There is also a post here that someone might be interested (also only here for completeness of this thread) http://tinyurl.com/kqzlaz
11. Thanks all very much.
12. Cheers.
13. Peace.

Jason Sjöbeck
www.sjobeck.com
Portland, Oregon, US

RE: Optimizing RoR and Passenger - Added by Eric Davis about 11 years ago

Jason Sjöbeck wrote:

We continue to use it. We continue to think it is sluggish when changing pages. We are totally fine & accept the fact that it takes 5 seconds to load up the very first time, who cares, one-time only thing upon loading it up, but our work is quite slowed-down by waiting the few seconds each & every time we touch a page or button or comment or change pages. I am not complaining. I am not accusing anything or any one. It might very well be our config'. We require SSL & I'm sure that even that tiny bit of overhead adds to it. To the meat of the matter .......

Something must be wrong, my Redmine (passenger w/SSL) takes maybe 10 seconds to start up and then it's 1-2 seconds per page. Maybe passenger is being reloaded at each page request? Have you tried watching passenger and see how it's responding to requests (e.g. spawning a new child each request)?

1. we have only allocated 1gb of RAM to the VM (ie: inside Xen) & we might double that

1GB should be fine unless you are swapping. I run Redmine with 2 other Rails apps on a 1GB server with memory to spare.

9. no we are not running Enterprise Edition of anything, let alone Ruby (we are in the mode of "building it" & "not buying it" right now).

Ruby Enterprise Edition is free and Open Source. I think it was named Enterprise as a sort of joke. http://www.rubyenterpriseedition.com

Portland, Oregon, US

I'm also from Portland (Aloha).

Eric Davis

RE: Optimizing RoR and Passenger - Added by Jason Sjöbeck about 11 years ago

Eric,

So helpful. Thanks.

That is funny, the moment I read the title, I didnt even bother to hit the URL for Ruby Enterprise. :) I just installed it & if it reduces RAM at all (let alone by 33%) & helps performance in any way, that'll indeed be worth it.

Good to know about the amount of RAM you use & performance youre getting. Encouraging. We'll get there too then. If I dont get it in too much longer, who knows, I might drop you a mail & see if I can buy an hour of your time, we'll see.

I am afraid I need to admit that I dont know how to debug Passenger at all. I have found precious little documentation on it so far.

Thanks so much for your tips.

Jason Sjöbeck

RE: Optimizing RoR and Passenger - Added by Brandon Dixon about 11 years ago

Jason Sjöbeck wrote:

Eric,
All,

Thanks so much for the very good information. Very much appreciated. We really dig on Redmine, great great web app'.

We continue to use it. We continue to think it is sluggish when changing pages. We are totally fine & accept the fact that it takes 5 seconds to load up the very first time, who cares, one-time only thing upon loading it up, but our work is quite slowed-down by waiting the few seconds each & every time we touch a page or button or comment or change pages. I am not complaining. I am not accusing anything or any one. It might very well be our config'. We require SSL & I'm sure that even that tiny bit of overhead adds to it. To the meat of the matter .......
1. we have only allocated 1gb of RAM to the VM (ie: inside Xen) & we might double that

Our current implementation is only at 1gb and also running in a VM. I doubt you are taxing your resources now and would suggest doing some load observations just to see the average usage of the device. I think you would be surprised to find that it is barely being touched.

2. we are using Passenger
3. we are not using Mongrel (I might try this later but only if no luck after a few more tries)

We are not using Mongrel here just because we have such a small load, but I came across this guide that was very detailed and thorough when looking for FastCGI instructions. Hopefully it will help when you decide to switch: http://ubuntuforums.org/showpost.php?p=4182270&postcount=1

4. we would like to get FastCGI working. (couldn't figure it out first try but will try again soon) If any one else has step-by-step HOWTO for enabling & using FastCGI, that would be most appreciated.

Give this guide a look - http://wiki.ousli.org/index.php/RedmineUbuntu
I am not sure what dist. you are using, but its clear enough that it should work on any version. I thought FastCGI would be hard to setup, but in the end I noticed realized it was so much easier than dealing with all the ruby business (I love Apache and find it easier to handle things there). One thing I did and that you too could take advantage of is making a copy of your current production Redmine implementation. Being that its a VM, all you would need to do is allocate some time to power it down, copy it out and then you would have a fully functional dev. machine to test out your FastCGI implementation on.

5. totally separately & off the topic of performance, we are just about down integrating SVN & the GUI to manage repositories using either method. (that will be great to have!) I do not believe this has anything to do with performance, but I only mention it here for full disclosure.

We too use SVN and have no issues at all. :-) It was easy to get into place and works like a charm. This link mentions SVN setup for your installation if you need any help here. http://www.drinkingbird.net/blog/articles/2008/02/27/setting-up-a-redmine-site-on-ubuntu

6. I had no idea about weBrick, so appreciate the explanation there (Eric) of what that is suggested for.
7. yes, we restart "httpd" after every edit. We have learned over the year that it is most wise to edit ONLY one variable & restart the web daemon & re-try. Lather, rinse, repeat.
8. we have not edited the IDLE variable at all. It sounds like it doesn't really matter (much?) so probably wont touch it.

From reading about Passenger it does matter, but when I changed it I did not experience much of a change. However, I should note that since posting this thread my Redmine installation is screaming fast. I initially had a small delay upon first load, but now I have no waiting at all and its up to par with the Redmine.org website. I have changed the IDLE time as well as looking into some simple optimizations for Apache.

9. no we are not running Enterprise Edition of anything, let alone Ruby (we are in the mode of "building it" & "not buying it" right now).
10. There is also a post here that someone might be interested (also only here for completeness of this thread) http://tinyurl.com/kqzlaz
11. Thanks all very much.
12. Cheers.
13. Peace.

Jason Sjöbeck
www.sjobeck.com
Portland, Oregon, US

RE: Optimizing RoR and Passenger - Added by Brandon Dixon about 11 years ago

Jason Sjöbeck wrote:

Eric,

So helpful. Thanks.

That is funny, the moment I read the title, I didnt even bother to hit the URL for Ruby Enterprise. :) I just installed it & if it reduces RAM at all (let alone by 33%) & helps performance in any way, that'll indeed be worth it.

Good to know about the amount of RAM you use & performance youre getting. Encouraging. We'll get there too then. If I dont get it in too much longer, who knows, I might drop you a mail & see if I can buy an hour of your time, we'll see.

I am afraid I need to admit that I dont know how to debug Passenger at all. I have found precious little documentation on it so far.

I didn't find much documentation either on this, but I did use the Passenger site to find out the meaning of some of the configuration variables.

http://www.modrails.com/documentation/Users%20guide.html#PassengerPoolIdleTime

I used these commands when monitoring Passenger activity and load:

passenger-memory-stats
passenger-status

Google around for sites that use the passenger-stress-test to debug their problems and that should help you in doing load testing there. I never got to using that command, but I came across a few sites that showed how they identified their problems and other statistics by using it. Hopefully that will help you if you ever get to that point.

Also, I used the Apache site along with some other sites to see how to optimize Apache and MySQL.

http://httpd.apache.org/docs/2.2/misc/perf-tuning.html
http://www.ibm.com/developerworks/linux/library/l-tune-lamp-2.html
http://www.debianhelp.co.uk/mysqlperformance.htm

Thanks so much for your tips.

Jason Sjöbeck

RE: Optimizing RoR and Passenger - Added by Eric Davis about 11 years ago

I'm also going to start looking at some easy performance optimizations. I've got a plugin that will load Redmine up with 100,000 issues. I'll just say this, it's a lot easier to find slow areas with that much data.

Eric

RE: Optimizing RoR and Passenger - Added by Brandon Dixon about 11 years ago

Great thinking. Can you post your results on this thread?

(1-10/10)