Nauhaie
2006-Jul-16 22:10 UTC
[Rails] Apache2.2 + Mongrel: what do you think about these perfs?
Hi all, I''ve been spending quite a lot of time trying to install a decent RoR server on my dedicated server (Ubuntu 6.06 LTS), and now, everything works. However, the performances are not really what I had expected... I would like to know what you think about it. Here is my config: 2GHz VIA proc, 1Gb RAM, SATA-II HD. I have apt-got ruby 1.8.4, mysql5 and installed rails 1.1.4 by means of rubygems (0.9.0). Then I installed the mysql extension (2.7}, mongrel (0.3.13.3) and mongrel cluster (0.2.0) and uploaded my app. Here is my mongrel_cluster.yml: --- port: "8000" environment: production pid_file: log/mongrel.pid servers: 3 Then, I compiled Apache2.2. Here are my configure options: ./configure --prefix=/usr/local/apache2 --enable-modules=''alias asis auth_basic auth_digest authn_file authz_user autoindex access cgi cgid charset_lite dir env http imagemap include log_config mime negotiation setenvif status deflate info proxy proxy_balancer rewrite so headers'' Not too much, and static only... I don''t see how I could improve this... Now, here is my vhost config: <VirtualHost *> ServerName dedibox DocumentRoot /home/noe/cukv3/public <Directory "/home/noe/cukv3/public"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> <Proxy balancer://cukv3> BalancerMember http://127.0.0.1:8000 BalancerMember http://127.0.0.1:8001 BalancerMember http://127.0.0.1:8002 </Proxy> ProxyPass /images ! ProxyPass /stylesheets ! ProxyPass /javascripts ! ProxyPass / balancer://cukv3/ ProxyPassReverse / balancer://cukv3/ </VirtualHost> The whole thing works, however, as I have said, I am not satisfied by the performances... Here is what I get for a middle-complexity action, which returns 10 articles from a given category (n-to-n relationship). (In fact, mysql''s CPU usage never gets > 3%, so it is clearly ruby that slows it down...) These benches have been realized with apache bench, from the box itself. So there is no delay due to the network. I know httperf is better, but I couldn''t manage to get it to work, because it took too much CPU. So, here are the results: 1) Direct connexion to a mongrel server: 1.1) Dynamic ab -n 100 -c 10 127.0.0.1:8000/articles/list?category_id=2 Result: 5.70 #/s 1.2) Static ab -n 10000 -c 10 127.0.0.1:8000/stylesheets/img/logo.gif Result: 439 #/s 2) Through Apache2.2 and mod_proxy_balancer 2.1) Dynamic ab -n 100 -c 10 127.0.0.1/articles/list?category_id=2 Result: 6.38 #/s 2.2) Static ab -n 100 -c 10 127.0.0.1/stylesheets/img/logo.gif Result: 1703 #/s Which seems to be unsufficient for production use... So, what do you think? Is it normal? Did I do something wrong? In fact, I would be interested in points of comparison, and thoughts about these results. Thank you very much! Nauhaie -- Posted via http://www.ruby-forum.com/.
s.ross
2006-Jul-16 22:31 UTC
[Rails] Apache2.2 + Mongrel: what do you think about these perfs?
Just as a sanity check, I have an under-development app that I switched over to production mode on a MacBook Pro (not the fastest server on earth) and httperf shows a single Mongrel serving up somewhere around 27 req/s for dynamic pages. Remember, this is a *laptop* I''m benchmarking. Your server should outpunch it by a significant amount. Nauhaie wrote:> > ab -n 100 -c 10 127.0.0.1:8000/articles/list?category_id=2 > Result: 5.70 #/s >-- View this message in context: http://www.nabble.com/Apache2.2-%2B-Mongrel%3A-what-do-you-think-about-these-perfs--tf1952024.html#a5353289 Sent from the RubyOnRails Users forum at Nabble.com.
Zed Shaw
2006-Jul-16 22:35 UTC
[Rails] Apache2.2 + Mongrel: what do you think about these perfs?
On Mon, 2006-07-17 at 00:09 +0200, Nauhaie wrote: Everything looks fine from first glance. <snip>> So, here are the results: > > 1) Direct connexion to a mongrel server: > > 1.1) Dynamic > > ab -n 100 -c 10 127.0.0.1:8000/articles/list?category_id=2 > Result: 5.70 #/s > > 1.2) Static > > ab -n 10000 -c 10 127.0.0.1:8000/stylesheets/img/logo.gif > Result: 439 #/s > > 2) Through Apache2.2 and mod_proxy_balancer > > 2.1) Dynamic > > ab -n 100 -c 10 127.0.0.1/articles/list?category_id=2 > Result: 6.38 #/s > > 2.2) Static > > ab -n 100 -c 10 127.0.0.1/stylesheets/img/logo.gif > Result: 1703 #/sYou should do one more test: 1) Create a small controller named "test_controller.rb" and put an index action in it that render_text "test" as the only thing it does. 2) Re-run your above test and see what kind of performance you get. This is most likely your max Rails performance, if other pages aren''t at this level then you have to work on the Rails side to get them faster. If this measurement is the same as your /articles test then you''ve got something configured wrong since it has to be faster. Check out ruby-prof as a way to get good performance tuning measurements for that specific action: http://rubyforge.org/projects/ruby-prof Specifically the part about using the ruby-prof library to measure one function. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.railsmachine.com/ -- Need Mongrel support?
Nauhaie
2006-Jul-17 06:13 UTC
[Rails] Re: Apache2.2 + Mongrel: what do you think about these perfs
Hi!> 1) Create a small controller named "test_controller.rb" and put an index > action in it that render_text "test" as the only thing it does. > 2) Re-run your above test and see what kind of performance you get.You are right, I should probably have done that in the first place... So, here are my results: Direct to Mongrel: ab -n 100 -c 10 127.0.0.1:8000/test ==> 45#/s Through Apache to 3 Mongrels: ab -n 100 -c 10 127.0.0.1/test ==> 45#/s, too Does it seem you right? Thank you! Nauhaie -- Posted via http://www.ruby-forum.com/.
Nauhaie
2006-Jul-17 21:10 UTC
[Rails] Re: Apache2.2 + Mongrel: what do you think about these perfs
If it might help, I have tried it with the same 3 Mongrels and Pound instead of Apache2.2 + mod_proxy_balancer. I get 6.14 #/s (I had 6.38 with last config) with my script. With the simple Hello World, I get 40.86 (45 with last config). It appears that Pound is no better than Apache2.2... Can someone confirm that please? I would really be interested in what performances you guys get, because I have pretty much nothing to compare with... Thank you! Nauhaie -- Posted via http://www.ruby-forum.com/.
Zed Shaw
2006-Jul-17 21:34 UTC
[Rails] Re: Apache2.2 + Mongrel: what do you think about these perfs
On Mon, 2006-07-17 at 23:10 +0200, Nauhaie wrote:> If it might help, I have tried it with the same 3 Mongrels and Pound > instead of Apache2.2 + mod_proxy_balancer. > > I get 6.14 #/s (I had 6.38 with last config) with my script. With the > simple Hello World, I get 40.86 (45 with last config). It appears that > Pound is no better than Apache2.2... Can someone confirm that please? > > I would really be interested in what performances you guys get, because > I have pretty much nothing to compare with...Yep, basically you''re putting your efforts in the wrong place. If you run a test controller and you get 40.86, and then your page gets 6.14, then changing out the balancer will do absolutely nothing for you. You''ve got to work on making your rails actions faster. Nothing can save you. You''re doomed. Time to work on the real problem. :-) Check out ruby-prof for some hints, also look at some earlier posts by Stefan Kaes and Scott Barron for other tools. Otherwise, just keep benching and tweaking until you find out the problem. Your production.log is the key to your problem. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.railsmachine.com/ -- Need Mongrel support?