<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>kodefoo - Home</title>
  <id>tag:www.kodefoo.com,2007:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.7.3">Mephisto Noh-Varr</generator>
  <link href="http://www.kodefoo.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.kodefoo.com/" rel="alternate" type="text/html"/>
  <updated>2007-05-10T18:31:35Z</updated>
  <entry xml:base="http://www.kodefoo.com/">
    <author>
      <name>robl</name>
    </author>
    <id>tag:www.kodefoo.com,2007-05-10:8</id>
    <published>2007-05-10T18:21:00Z</published>
    <updated>2007-05-10T18:31:35Z</updated>
    <link href="http://www.kodefoo.com/2007/5/10/conference-time-again" rel="alternate" type="text/html"/>
    <title>Conference time again</title>
<content type="html">
            &lt;p&gt;&lt;img src=&quot;http://farm1.static.flickr.com/90/211979102_fe0ad94248_s_d.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Yes, it&#8217;s that time of year again and Kodefoo will be heading off to both &lt;a href=&quot;http://2007.xtech.org&quot;&gt;XTech 2007&lt;/a&gt; and &lt;a href=&quot;http://www.reboot.dk&quot;&gt;Reboot 9.0&lt;/a&gt;.  We&#8217;ll be taking on some session charing duties and we&#8217;re also running the lightning talks session (think 20:20) at XTech this year.  The sessions we&#8217;ll be involved in are :&lt;/p&gt;

&lt;table class=&quot;en_list-data&quot;&gt;

    &lt;tr&gt;&lt;th&gt;Time&lt;/th&gt;&lt;th&gt;Room&lt;/th&gt;&lt;th&gt;Session&lt;/th&gt;&lt;/tr&gt;

    &lt;tr&gt;
        &lt;td&gt;2007-05-16 16:00&lt;/td&gt;
        &lt;td&gt;Amphitheatre A&lt;/td&gt;
        &lt;td&gt;
            &lt;a href=&quot;http://2007.xtech.org/public/schedule/detail/228&quot;&gt;Nabaztag and the Emergence of the Internet of Things&lt;/a&gt;&lt;br /&gt;Rafi Haladjian (Violet)
        &lt;/td&gt;

    &lt;/tr&gt;

    &lt;tr&gt;
        &lt;td&gt;2007-05-16 16:45&lt;/td&gt;
        &lt;td&gt;Amphitheatre A&lt;/td&gt;
        &lt;td&gt;
            &lt;a href=&quot;http://2007.xtech.org/public/schedule/detail/82&quot;&gt;Pipelines: Plumbing for the next web&lt;/a&gt;&lt;br /&gt;Ian Forrester (BBC)
        &lt;/td&gt;

    &lt;/tr&gt;

    &lt;tr&gt;
        &lt;td&gt;2007-05-17 11:00&lt;/td&gt;
        &lt;td&gt;Amphitheatre C&lt;/td&gt;
        &lt;td&gt;
            &lt;a href=&quot;http://2007.xtech.org/public/schedule/detail/17&quot;&gt;Making Massive Datasets Universally Accessible and Useful&lt;/a&gt;&lt;br /&gt;Jon Trowbridge (Google, Inc.)
        &lt;/td&gt;

    &lt;/tr&gt;

    &lt;tr&gt;
        &lt;td&gt;2007-05-17 11:45&lt;/td&gt;
        &lt;td&gt;Amphitheatre C&lt;/td&gt;
        &lt;td&gt;
            &lt;a href=&quot;http://2007.xtech.org/public/schedule/detail/25&quot;&gt;Aware and Loca: Letting others know where you are&lt;/a&gt;&lt;br /&gt;John Evans (HIIT)
        &lt;/td&gt;

    &lt;/tr&gt;

    &lt;tr&gt;
        &lt;td&gt;2007-05-18 09:00&lt;/td&gt;
        &lt;td&gt;Grand Palais&lt;/td&gt;
        &lt;td&gt;
            &lt;a href=&quot;http://2007.xtech.org/public/schedule/detail/190&quot;&gt;The implications of OpenID&lt;/a&gt;&lt;br /&gt;Simon Willison (-)
        &lt;/td&gt;

    &lt;/tr&gt;

    &lt;tr&gt;
        &lt;td&gt;2007-05-18 09:45&lt;/td&gt;
        &lt;td&gt;Grand Palais&lt;/td&gt;
        &lt;td&gt;
            &lt;a href=&quot;http://2007.xtech.org/public/schedule/detail/45&quot;&gt;Open &lt;span class=&quot;caps&quot;&gt;AIM&lt;/span&gt; as it relates to you&lt;/a&gt;&lt;br /&gt;Thomas Crenshaw (AIM/AOL)
        &lt;/td&gt;

    &lt;/tr&gt;

&lt;/table&gt;
&amp;nbsp;
&lt;p&gt;I can&#8217;t wait for these sessions, so I&#8217;d highly recommend attending if you can.  If you&#8217;re in Paris and fancy meeting up then let us know !&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.kodefoo.com/">
    <author>
      <name>robl</name>
    </author>
    <id>tag:www.kodefoo.com,2007-03-27:6</id>
    <published>2007-03-27T09:43:00Z</published>
    <updated>2007-03-27T09:44:37Z</updated>
    <category term="Products"/>
    <link href="http://www.kodefoo.com/2007/3/27/picture-perfect" rel="alternate" type="text/html"/>
    <title>Picture Perfect</title>
<summary type="html">&lt;p&gt;&lt;img src=&quot;http://farm1.static.flickr.com/3/3428491_e3eae923dc_s_d.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;We&#8217;ve recently packaged up some software we created some time ago as our first product.  Announcing &#8216;&lt;a href=&quot;http://www.mmsability.com&quot;&gt;MMSAbility&lt;/a&gt;&#8217;.  It allows you to easily accept &lt;span class=&quot;caps&quot;&gt;MMS&lt;/span&gt;/Picture messages into your product-set by providing a (MMS) vendor-neutral interface for picture message parsing.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;&lt;img src=&quot;http://farm1.static.flickr.com/3/3428491_e3eae923dc_s_d.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;We&#8217;ve recently packaged up some software we created some time ago as our first product.  Announcing &#8216;&lt;a href=&quot;http://www.mmsability.com&quot;&gt;MMSAbility&lt;/a&gt;&#8217;.  It allows you to easily accept &lt;span class=&quot;caps&quot;&gt;MMS&lt;/span&gt;/Picture messages into your product-set by providing a (MMS) vendor-neutral interface for picture message parsing.&lt;/p&gt;
&lt;p&gt;We&#8217;ve recently packaged up some software we created some time ago as our first product.  Announcing &#8216;&lt;a href=&quot;http://www.mmsability.com&quot;&gt;MMSAbility&lt;/a&gt;&#8217;.  It allows you to easily accept &lt;span class=&quot;caps&quot;&gt;MMS&lt;/span&gt;/Picture messages into your product-set by providing a (MMS) vendor-neutral interface for picture message parsing.  The diagram below gives a quick overview :&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://www.mmsability.com/images/mmsability.png&quot; alt=&quot;MMSAbility&quot;&gt;&lt;/p&gt;


	&lt;p&gt;So if you&#8217;re interested in using picture messages to create community in your products, then get in &lt;a href=&quot;http://www.mmsability.com/contact.html&quot;&gt;touch&lt;/a&gt;.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.kodefoo.com/">
    <author>
      <name>robl</name>
    </author>
    <id>tag:www.kodefoo.com,2007-02-19:3</id>
    <published>2007-02-19T00:43:00Z</published>
    <updated>2007-02-22T15:05:49Z</updated>
    <category term="Talks"/>
    <link href="http://www.kodefoo.com/2007/2/19/take-a-rest-with-rails" rel="alternate" type="text/html"/>
    <title>Take a REST with Rails</title>
<summary type="html">&lt;p&gt;&lt;img src=&quot;http://farm1.static.flickr.com/46/161207796_c52606ef7b_s_d.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;As my talk for our local Ruby User Group &lt;a href=&quot;http://www.nwrug.org/&quot;&gt;meetup&lt;/a&gt; , I&#8217;ve prepared a presentation about the new RESTful features in Rails 1.2.  It covers changes to routing, generators and gives a quick overview of the &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; architectural style, where it originated and how it applies to Rails.  To demonstrate these concepts, a RESTful blog is created.  This blog is then used as part of a final example that uses ActiveResource to consume RESTful resources.&lt;/p&gt;


	&lt;p&gt;Download &#8220;Take a &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; with Rails&#8221; &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/19/TakeARestWithRails_1.odp&quot;&gt;(odp)&lt;/a&gt; &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/19/TakeARestWithRails_1.pdf&quot;&gt;(pdf)&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Download the sample code &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/22/blog.tar.gz&quot;&gt;blog.tar.gz&lt;/a&gt; and &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/22/slurpr.tar.gz&quot;&gt;slurpr.tar.gz&lt;/a&gt;&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;&lt;img src=&quot;http://farm1.static.flickr.com/46/161207796_c52606ef7b_s_d.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;As my talk for our local Ruby User Group &lt;a href=&quot;http://www.nwrug.org/&quot;&gt;meetup&lt;/a&gt; , I&#8217;ve prepared a presentation about the new RESTful features in Rails 1.2.  It covers changes to routing, generators and gives a quick overview of the &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; architectural style, where it originated and how it applies to Rails.  To demonstrate these concepts, a RESTful blog is created.  This blog is then used as part of a final example that uses ActiveResource to consume RESTful resources.&lt;/p&gt;


	&lt;p&gt;Download &#8220;Take a &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; with Rails&#8221; &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/19/TakeARestWithRails_1.odp&quot;&gt;(odp)&lt;/a&gt; &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/19/TakeARestWithRails_1.pdf&quot;&gt;(pdf)&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Download the sample code &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/22/blog.tar.gz&quot;&gt;blog.tar.gz&lt;/a&gt; and &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/22/slurpr.tar.gz&quot;&gt;slurpr.tar.gz&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://farm1.static.flickr.com/46/161207796_c52606ef7b_s_d.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;As my talk for our local Ruby User Group &lt;a href=&quot;http://www.nwrug.org/&quot;&gt;meetup&lt;/a&gt; , I&#8217;ve prepared a presentation about the new RESTful features in Rails 1.2.  It covers changes to routing, generators and gives a quick overview of the &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; architectural style, where it originated and how it applies to Rails.  To demonstrate these concepts, a RESTful blog is created.  This blog is then used as part of a final example that uses ActiveResource to consume RESTful resources.&lt;/p&gt;


	&lt;p&gt;Download &#8220;Take a &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; with Rails&#8221; &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/19/TakeARestWithRails.odp&quot;&gt;(odp)&lt;/a&gt; &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/19/TakeARestWithRails.pdf&quot;&gt;(pdf)&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Download the sample code &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/22/blog.tar.gz&quot;&gt;blog.tar.gz&lt;/a&gt; and &lt;a href=&quot;http://www.kodefoo.com/assets/2007/2/22/slurpr.tar.gz&quot;&gt;slurpr.tar.gz&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Post-Talk update&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;I was pleased with the talk and there were some interesting questions at the end so I thought I&#8217;d compile a set of &#8216;more complete&#8217; answers and document them here &#8230;&lt;/p&gt;


	&lt;p&gt;1. Does the number of routes increase from using the restful approach ?&lt;/p&gt;


&lt;blockquote&gt;
	&lt;p&gt;It depends largely if you originally relied on the default controller/action/id model or if you try and create more intuitive routes.  I think the &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; approach provides a more intuitive &lt;span class=&quot;caps&quot;&gt;URI&lt;/span&gt; structure, so if you prefer this model then I think the size of your routing file will be reduced by using the &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; approach.  See &lt;a href=&quot;http://weblog.rubyonrails.org/2006/7/20/scott-raymond-on-refactoring-to-rest&quot;&gt;here&lt;/a&gt; for more interesting stats on this subject.&lt;/p&gt;

&lt;/blockquote&gt;




	&lt;p&gt;2. Which elements of simply_restful have been integrated into Rails 1.2 ?&lt;/p&gt;


&lt;blockquote&gt;
	&lt;p&gt;My original answer wasn&#8217;t quite correct as I was confused by the map.resources nested block invocation.  As part of the  integration into the rails core the functionality of map.resources was modified to include this nested block form.  So the answer is map.resources (with modifications), generators and route helpers.  For more information see &lt;a href=&quot;http://weblog.rubyonrails.org/2006/8/1/simply-restful-in-rails-edge&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;/blockquote&gt;




	&lt;p&gt;3.  How does Rails manage the fact that all browsers don&#8217;t support all the &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt; methods required (specifically &lt;span class=&quot;caps&quot;&gt;PUT&lt;/span&gt;/DELETE) ?&lt;/p&gt;


&lt;blockquote&gt;
	&lt;p&gt;With a hack !  Using the form_for helper with one of the new route helpers will cause a hidden field &#8216;_method&#8217; to be added with the &#8216;real&#8217; action specified whilst the form itself will use &lt;span class=&quot;caps&quot;&gt;POST&lt;/span&gt; to submit.  Rails then checks the _method variable and actually performs the request routing using the &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt; method specified in _method.&lt;/p&gt;

&lt;/blockquote&gt;




	&lt;p&gt;4.  What about service discovery ?&lt;/p&gt;


&lt;blockquote&gt;
	&lt;p&gt;I thought that &lt;span class=&quot;caps&quot;&gt;WSDL&lt;/span&gt; could be used for service discovery and it turns out that this is true, at least as far as &lt;span class=&quot;caps&quot;&gt;WSDL 2&lt;/span&gt;.0 is concerned !.  This is more of a &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; question than a &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; on Rails question and I think the (quickest) explanation I could find was :&lt;/p&gt;

&lt;/blockquote&gt;




&lt;blockquote&gt;
	&lt;p&gt;What&#8217;s the alternative to &lt;span class=&quot;caps&quot;&gt;WSDL&lt;/span&gt; ? There was a proposal for a Web Resource Definition Language, sortof a RESTful &lt;span class=&quot;caps&quot;&gt;WSDL&lt;/span&gt;. http://www.prescod.net/rest/wrdl/wrdl.html . That seems somewhat moribund. Potentially, the answer could be &lt;span class=&quot;caps&quot;&gt;WSDL 2&lt;/span&gt;.0, which would leverage the &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt;-friendly features of &lt;span class=&quot;caps&quot;&gt;SOAP 1&lt;/span&gt;.2. There doesn&#8217;t seem to be much demand among customers of &lt;span class=&quot;caps&quot;&gt;WSDL 2&lt;/span&gt;.0 for this, however, so the working group hasn&#8217;t gotten around to working on this yet. More generally, I think the &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; people would say that if you have the &lt;span class=&quot;caps&quot;&gt;URI&lt;/span&gt; of a RESTful service and the schemas of the representations being transferred, you don&#8217;t need &lt;span class=&quot;caps&quot;&gt;WSDL&lt;/span&gt;, since the basic actions and message exchange patterns are assumed to be those baked into &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt;. (from a comment on &lt;a href=&quot;http://www.adambosworth.net/archives/000016.html&quot;&gt;Adam Bosworth&lt;/a&gt;.)&lt;/p&gt;

&lt;/blockquote&gt;




	&lt;p&gt;I really enjoyed the debate and questions from the evening, although I&#8217;ll probably run through a few more practice sessions before I try and code in front of a room of 20 people again :)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.kodefoo.com/">
    <author>
      <name>robl</name>
    </author>
    <id>tag:www.kodefoo.com,2007-02-18:1</id>
    <published>2007-02-18T23:42:00Z</published>
    <updated>2007-03-08T00:28:07Z</updated>
    <link href="http://www.kodefoo.com/2007/2/18/deploying-rails-on-ubuntu-dapper" rel="alternate" type="text/html"/>
    <title>Deploying Rails on Ubuntu Dapper</title>
<summary type="html">&lt;p&gt;&lt;img src=&quot;http://farm1.static.flickr.com/75/355072114_0516327fd9_s_d.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;Deploying Rails on Ubuntu Dapper can be a tricky proposition, with the typical solution using Apache as a proxy to Mongrel.  This article demonstrates how to setup Apache2.2 (including Dapper .deb packages) with Mongrel utilizing the mod_proxy_balancer module for Apache.&lt;/p&gt;


	&lt;p&gt;Ubuntu is fast becoming the distribution of choice for many people, having the ease of deployment and solid package management system that you would expect from a Debian based distribution and also benefits from a fast release cycle that results in up to date versions of many popular packages.  In particular, Ubuntu &#8216;Dapper&#8217; is the first Ubuntu release to provide long term support (6 years from release) and has achieved a healthy level of security and stability (in no small part due to it&#8217;s Debian roots).&lt;/p&gt;


	&lt;p&gt;Currently, the most popular Rails deployment stack is Linux, Apache 2.2, Mongrel and MySQL.  This can present a problem when attempting to install with Ubuntu Dapper as Apache 2.0 is the only available Apache package within the official Dapper repositories.  There is always the option to compile a version of Apache from source (which certainly has some benefits) however  all the benefits of using a package management system are lost when taking this approach.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;&lt;img src=&quot;http://farm1.static.flickr.com/75/355072114_0516327fd9_s_d.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;Deploying Rails on Ubuntu Dapper can be a tricky proposition, with the typical solution using Apache as a proxy to Mongrel.  This article demonstrates how to setup Apache2.2 (including Dapper .deb packages) with Mongrel utilizing the mod_proxy_balancer module for Apache.&lt;/p&gt;


	&lt;p&gt;Ubuntu is fast becoming the distribution of choice for many people, having the ease of deployment and solid package management system that you would expect from a Debian based distribution and also benefits from a fast release cycle that results in up to date versions of many popular packages.  In particular, Ubuntu &#8216;Dapper&#8217; is the first Ubuntu release to provide long term support (6 years from release) and has achieved a healthy level of security and stability (in no small part due to it&#8217;s Debian roots).&lt;/p&gt;


	&lt;p&gt;Currently, the most popular Rails deployment stack is Linux, Apache 2.2, Mongrel and MySQL.  This can present a problem when attempting to install with Ubuntu Dapper as Apache 2.0 is the only available Apache package within the official Dapper repositories.  There is always the option to compile a version of Apache from source (which certainly has some benefits) however  all the benefits of using a package management system are lost when taking this approach.&lt;/p&gt;
&lt;p&gt;Ubuntu is fast becoming the distribution of choice for many people, having the ease of deployment and solid package management system that you would expect from a Debian based distribution and also benefits from a fast release cycle that results in up to date versions of many popular packages.  In particular, Ubuntu &#8216;Dapper&#8217; is the first Ubuntu release to provide long term support (6 years from release) and has achieved a healthy level of security and stability (in no small part due to it&#8217;s Debian roots).&lt;/p&gt;


	&lt;p&gt;Currently, the most popular Rails deployment stack is Linux, Apache 2.2, Mongrel and MySQL.  This can present a problem when attempting to install with Ubuntu Dapper as Apache 2.0 is the only available Apache package within the official Dapper repositories.  There is always the option to compile a version of Apache from source (which certainly has some benefits) however  all the benefits of using a package management system are lost when taking this approach.&lt;/p&gt;


	&lt;h2&gt;The Mongrel based deployment stack&lt;/h2&gt;


	&lt;p&gt;Mongrel is (currently) the preferred application server for deploying Rails in a commercial environment.  There are other solutions e.g. mod_fcgid or lighttpd, however these have become less popular due to instability or lack of support.&lt;/p&gt;


	&lt;p&gt;The preferred configuration involves using Apache as a proxy server, that sends Rails requests to Mongrel whilst serving requests for static content itself e.g. images or &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt;.  Apache is very good at serving static content whereas Mongrel excels at serving Ruby, thus each server performs tasks it is suited to.  The diagram below demonstrates this architecture :&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://www.gliffy.com/pubdoc/1161329/L.jpg&quot;&gt;&lt;/p&gt;


	&lt;h2&gt;Why so many Mongrels ?&lt;/h2&gt;


	&lt;p&gt;Mongrel is a Web server (and &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt; library) for Ruby applications.  It&#8217;s capable of running applications developed using the Ruby on Rails, Nitro and Camping frameworks.  Unfortunately, the Rails framework isn&#8217;t &lt;a href=&quot;http://en.wikipedia.org/wiki/Thread-safety&quot;&gt;thread-safe&lt;/a&gt;.  This results in a Mongrel instance having to handle &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt; requests serially.  This is obviously a problem for a site with a constant stream of traffic, as Mongrel wouldn&#8217;t be able to process concurrent requests.&lt;/p&gt;


	&lt;p&gt;The answer to this problem is to run many instances of Mongrel on different ports and proxy requests to them.  This can be achieved in a number of ways, but the most popular is to use Apache 2.2 with mod_proxy_balancer (as shown in the diagram above).  This does mean there is a configuration overhead in determining the optimum number of running Mongrel instances for your application (which will be examined later).  Managing a large number of Mongrel instances is a time consuming exercise and is made easier by mongrel_cluster.  mongrel_cluster is a set of scripts that allows easy management of Mongrel instances (across many Rails applications) via the init system.&lt;/p&gt;


	&lt;h2&gt;Installing Ruby, Rails and MySQL&lt;/h2&gt;


	&lt;p&gt;These are the meat and bones of our system, and are easily installed using a combination of the apt and Ruby gems package management systems :&lt;/p&gt;


	&lt;p&gt;&lt;em&gt;&lt;span class=&quot;caps&quot;&gt;NOTE&lt;/span&gt;:&lt;/em&gt;  You will need to have enabled the Universe repository to obtain some of these packages.&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby 
sudo wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz
tar -xvzf rubygems-0.9.2.tgz
cd rubygems-0.9.2
sudo ruby setup.rb
sudo gem install rails --include-dependencies
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;You can try creating a test Rails application by running :&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
rails railsapp
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;This should create a directory called &#8216;railsapp&#8217; with the standard Rails application skeleton.&lt;/p&gt;


	&lt;h2&gt;Installing Mongrel&lt;/h2&gt;


	&lt;p&gt;You&#8217;ll need both Ruby and some build packages for Mongrel to be installed on your system :&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
sudo apt-get install build-essential ruby1.8-dev ruby1.8
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;You can then install Mongrel as a Ruby Gem (this should install all Ruby dependencies automagically) :&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
sudo gem install mongrel
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Test your Mongrel install by running Mongrel in the root of a Rails application.  If all is ok, you should be able to browse to your rails application at &lt;code&gt;http://localhost:3000&lt;/code&gt; :&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
cd rails_app/
mongrel_rails start -d
mongrel_rails stop
&lt;/code&gt;
&lt;/pre&gt;

	&lt;h2&gt;Installing mongrel_cluster&lt;/h2&gt;


	&lt;p&gt;Once you have a successful Mongrel install, you can install mongrel cluster enabling you to manage your Mongrel instances.&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
sudo gem install mongrel_cluster
&lt;/code&gt;
&lt;/pre&gt;

	&lt;h2&gt;Installing Apache 2.2&lt;/h2&gt;


	&lt;p&gt;Kodefoo have prepared a set of Apache 2.2 packages (for the i386 architecture).  These packages have been backported from Ubuntu Feisty to Ubuntu Dapper.  The packages are used for commercial hosting of Rails applications on Ubuntu Dapper by Kodefoo. The packages provided include mod_php and mod_perl for running &lt;span class=&quot;caps&quot;&gt;LAMP&lt;/span&gt; stacks in addition to a Rails environment.  The packages are provided in an apt repository to ease the install and update process.  A package update process runs on a daily basis, checking to see if new packages have been released, if new packages have been made available for Feisty then these are backported for Dapper and added to the apt repository.&lt;/p&gt;


	&lt;p&gt;Before using this repository you must agree to the &lt;a href=&quot;/tou.html&quot;&gt;Terms Of Use&lt;/a&gt; .  If you are unable to agree to this then &lt;strong&gt;do not&lt;/strong&gt; use this repository.&lt;/p&gt;


	&lt;p&gt;Add the following line to your &lt;code&gt;/etc/apt/sources.list&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;deb http://packages.kodefoo.com/ dapper main&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Import the kodefoo repository &lt;span class=&quot;caps&quot;&gt;GPG&lt;/span&gt; key into your apt repository keyring :&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
wget http://packages.kodefoo.com/release.asc
sudo apt-key add release.asc
&lt;/pre&gt;
&lt;/code&gt;

	&lt;p&gt;Update the package indexes and install Apache 2.2 :&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
sudo apt-get update
sudo apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils
&lt;/code&gt;
&lt;/pre&gt;

	&lt;h2&gt;Configuring Apache 2.2, Mongrel and mongrel_cluster&lt;/h2&gt;


	&lt;p&gt;There is a very good mongrel_cluster configuration guide available at the &lt;a href=&quot;http://mongrel.rubyforge.org/docs/mongrel_cluster.html&quot;&gt;Mongrel site&lt;/a&gt;.  It&#8217;s recommended you follow the guide there to configure your mongrel_cluster instances.&lt;/p&gt;


	&lt;p&gt;For the purposes of configuring Apache 2.2, it is assumed the mongrel_cluster has been configured to run three Mongrel instances starting at port 8000 (so there will be Mongrel instances listening for &lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt; requests on ports 8000, 8001 and 8002).  The example below should be adjusted appropriately if your configuration differs.&lt;/p&gt;


	&lt;p&gt;The following virtual host file proxies Rails requests to your local Mongrel instances (invoked via mongrel_cluster) but allows Apache to serve the static content.&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
&amp;lt;VirtualHost *&amp;gt;
   ServerName www.yourserver.com

   DocumentRoot /var/www/railsapp/public/

   &amp;lt;Directory &quot;/var/www/railsapp/public&quot;&amp;gt;
     Options FollowSymLinks
     AllowOverride None
     Order allow,deny
     Allow from all
   &amp;lt;/Directory&amp;gt;

   ErrorLog logs/railsapp_errors_log
   CustomLog logs/railsapp_log combined

   # this not only blocks access to .svn directories, but makes it appear
   # as though they aren't even there, not just that they are forbidden
   &amp;lt;DirectoryMatch &quot;^/.*/\.svn/&quot;&amp;gt;
     ErrorDocument 403 /404.html
     Order allow,deny
     Deny from all
     Satisfy All
   &amp;lt;/DirectoryMatch&amp;gt;

   &amp;lt;Proxy *&amp;gt;
    Order allow,deny
    Allow from all
   &amp;lt;/Proxy&amp;gt;

   &amp;lt;Proxy balancer://mongrel_cluster&amp;gt;
     BalancerMember http://127.0.0.1:8000
     BalancerMember http://127.0.0.1:8001
     BalancerMember http://127.0.0.1:8002
   &amp;lt;/Proxy&amp;gt;

   # This passes through remote_user to mongrel
   RewriteEngine On
   RewriteCond %{LA-U:REMOTE_USER} (.+)
   RewriteRule . - [E=RU:%1]
   RequestHeader add X-Forwarded-User %{RU}e

   # Now standard rewrite rules
   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -d
   RewriteRule ^(.+[^/])$ $1/ [R]

   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} \.php
   RewriteRule ^(.*)$ $1 [QSA,L]

   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}/index.html -f
   RewriteRule ^(.*)$ $1/index.html [QSA,L]

   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}/index.php -f
   RewriteRule ^(.*)$ $1/index.php [QSA,L]

   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -d
   RewriteRule ^(.*)[^/]$ $1/ [QSA,L]

   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
   RewriteRule ^/(.*)$ balancer://mongrelcluster%{REQUEST_URI} [P,QSA,L]

&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;This file can be saved in &lt;code&gt;/etc/apache2/sites-enabled/yoursite&lt;/code&gt; and enabled with :&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
sudo a2ensite
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;The configuration can be tested using :&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
sudo apache2ctl -t
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;Providing there were no errors, the installation and configuration should now be complete.  When Apache is restarted, the Rails application will be served by Apache and Mongrel.  If you have configured mongrel_cluster as an init script then Apache and Mongrel can be restarted using :&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
sudo /etc/init.d/mongrel_cluster restart &#38;&#38; sudo /etc/init.d/apache2 restart
&lt;/code&gt;
&lt;/pre&gt;

	&lt;h2&gt;Performance tuning hints and tips&lt;/h2&gt;


	&lt;p&gt;There are a number of areas that can be tuned for performance using this architecture.  Typical considerations include :&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;The number of Mongrel instances, configured per Rails application served.  There is no &#8216;magic&#8217; number, however Kodefoo typically find a minimum of four instances is required.  To perform individual application tuning look at &lt;a href=&quot;http://mongrel.rubyforge.org/docs/how_many_mongrels.html&quot;&gt;How Many Mongrel Instances Should I Run ?&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;The default Apache 2.2 configuration can be improved (some suggestions &lt;a href=&quot;http://virtualthreads.blogspot.com/2006/01/tuning-apache-part-1.html&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://linuxgazette.net/123/vishnu.html&quot;&gt;here&lt;/a&gt;) and using one of the newer Apache &lt;span class=&quot;caps&quot;&gt;MPM&lt;/span&gt; models can certainly &lt;a href=&quot;http://tomcopeland.blogs.com/juniordeveloper/2006/11/apache_22_and_t.html&quot;&gt;help&lt;/a&gt; &lt;/li&gt;
		&lt;li&gt;The use of &lt;a href=&quot;http://www.danga.com/memcached/&quot;&gt;memcached&lt;/a&gt; can also help in moving load away from the database layer to a memory cached distributed layer.  This can be useful for scaling large sites with high traffic levels, some pointers can be found &lt;a href=&quot;http://nubyonrails.com/articles/2006/08/17/memcached-basics-for-rails&quot;&gt;here&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;We&#8217;ll be publishing a performance tuning article in the near future, so check back soon.&lt;/p&gt;


	&lt;h3&gt;Attribution&lt;/h3&gt;


	&lt;p&gt;Articles consulted whilst writing this article :&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/&quot;&gt;Time For  A Grown-Up Server&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://mongrel.rubyforge.org/&quot;&gt;Mongrel&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://www.simplisticcomplexity.com/2006/8/13/apache-2-2-mod_proxy_balancer-mongrel-on-ubuntu-6-06&quot;&gt;Apache2.2, mod_proxy_balancer &#38; Mongrel on Ubuntu 6.06&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
          </content>  </entry>
</feed>
