<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Rubynaut: Scaling a Rails app (Part 1 of 3)</title>
    <link>http://www.rubynaut.net/articles/2007/10/10/scaling-a-rails-app-part-1-of-3</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Scaling a Rails app (Part 1 of 3)</title>
      <description>&lt;p&gt;One of the most interesting topic in the RailsConf was &lt;em&gt;Scaling your Rails app&lt;/em&gt;. There are 2 ways of doing it:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;adapt your code&lt;/li&gt;
		&lt;li&gt;adapt your servers&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;But the second one will not help to make your code faster. It will just help to give maximum resources to compute it right.&lt;/p&gt;


	&lt;p&gt;Summaries from the conference (&lt;em&gt;sorry for the so few litterature it will be only a summarize&lt;/em&gt;):&lt;/p&gt;


	&lt;h3&gt;Some theories&lt;/h3&gt;


	&lt;p&gt;These theories are for big websites with millions of hits every month. This can involve thousand of servers, different location, ... &lt;span class="caps"&gt;BTW&lt;/span&gt; some tips can be use to help smaller configurations.&lt;/p&gt;


	&lt;p&gt;The 7 layers to be considered, &lt;em&gt;a la &lt;span class="caps"&gt;OSI&lt;/span&gt;&lt;/em&gt;. &lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;frontend &lt;/li&gt;
		&lt;li&gt;proxy&lt;/li&gt;
		&lt;li&gt;application server&lt;/li&gt;
		&lt;li&gt;application&lt;/li&gt;
		&lt;li&gt;backend (Db , filesystem)&lt;/li&gt;
		&lt;li&gt;OS&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h4&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt;&lt;/h4&gt;


	&lt;p&gt;Nice website to check your &lt;span class="caps"&gt;DNS&lt;/span&gt; configuration: &lt;a href="http://www.dnsstuff.com/"&gt;dnsstuff.com&lt;/a&gt;
Good tool to optimize your &lt;span class="caps"&gt;DNS&lt;/span&gt;: speed, dispatching, and so on&amp;#8230;: &lt;a href="http://www.powerdns.com/"&gt;powerdns&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;DNS&lt;/span&gt; can be quite fast to address the right server from a request, scripts allow to manage complex configurations. The tip is to use 1 &lt;span class="caps"&gt;DNS&lt;/span&gt; entry per 1 controller, then managing part of the routing.&lt;/p&gt;


	&lt;h4&gt;Frontend and Proxy&lt;/h4&gt;


	&lt;p&gt;Load balancing is about dispatching requests taking in account the charge of each cluster.&lt;/p&gt;


	&lt;p&gt;Load balancers:
    &lt;a href="http://varnish.projects.linpro.no/"&gt;Varnish&lt;/a&gt;
    &lt;a href="http://haproxy.1wt.eu/"&gt;HAProxy&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Both look promising and HAProxy seems to be more and more popular.&lt;/p&gt;


	&lt;p&gt;Front end with load balancer:
    &lt;a href="http://wiki.codemongers.com/Main"&gt;Nginx&lt;/a&gt; : fast, low memory usage, http server with load balancing, easy configuration, very good in front of mongrel cluster.    
    Apache 2.2 + mod_proxy_balancer, you can find how to setup it in previous post: &lt;a href="http://www.rubynaut.net/articles/2007/09/22/apache-mongrel-cluster-rails-are-on-a-load-balancer"&gt;apapche, mongrel cluster, rails on a load balancer&lt;/a&gt;&lt;/p&gt;


	&lt;h4&gt;Application server&lt;/h4&gt;


	&lt;ul&gt;
	&lt;li&gt;mongrel server: enough for a personnal server
           gem install mongrel
           mongrel_rails start (&lt;a href="http://mongrel.rubyforge.org/docs/"&gt;more information&lt;/a&gt;)&lt;/li&gt;
		&lt;li&gt;mongrel_cluster: useful to scale up your configuration, need at least a multi-processor or multi server environnment.
           gem install mongrel_cluster 
           mongrel_rails cluster::configure &amp;#8230;
           mongrel_rails cluster::start&lt;/li&gt;
		&lt;li&gt;Evented Mongrel (&lt;a href="http://swiftiply.swiftcore.org/"&gt;swiftiply&lt;/a&gt;): it&amp;#8217;s a mongrel based an event triggering&lt;/li&gt;
		&lt;li&gt;jruby / glassfish: the technology java comes with some good environment to speed up part of your application like connection to database (jdbc, pool connection)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;&lt;em&gt;to be continued (application, backend, OS, and some home benchmark)&lt;/em&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 10 Oct 2007 20:32:53 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:471f1308-1501-4362-a631-494232b27410</guid>
      <author>stephane</author>
      <link>http://www.rubynaut.net/articles/2007/10/10/scaling-a-rails-app-part-1-of-3</link>
    </item>
  </channel>
</rss>
