Nick Sieger: RailsConf: Ezra Zygmuntowicz - Rails Deployment http://blog.nicksieger.com/articles/2006/06/24/railsconf-ezra-rails-deployment en-us 40 RailsConf: Ezra Zygmuntowicz - Rails Deployment <p><a href="http://brainspl.at/">Ezra</a>: Programming in Ruby for 3 years, Rails for 2. Just another Ruby hacker, he says. <em>Right!</em></p> <h2>Yakima Herald</h2> <ul> <li><a href="http://yakimaherald.com">http://yakimaherald.com</a> &#8211; Local newspaper website</li> <li>CMS</li> <li>Lots of non-SQL content</li> <li>Classified and obituary workflow</li> <li>Internal credit card transaction</li> </ul> <h2>Data Aggregation</h2> <ul> <li>Mysql</li> <li>XML feeds from AP</li> <li>RSS and Atom feeds from parent newspaper</li> <li>Proprietary database for articles <ul> <li>Yucky Vendorscript</li> <li>Crusty OS 9 server!</li> <li>Wrote DSL to emit script over a socket to remote machine</li> </ul></li> </ul> <h2>Deployment</h2> <ul> <li>Apache? Seems to be the industry standard&#8230;</li> </ul> <div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">class </span><span class="class">ApacheWithFCGI</span> <span class="punct">&lt;</span> <span class="constant">ActiveRecord</span><span class="punct">::</span><span class="constant">Base</span> <span class="ident">has_many</span> <span class="symbol">:random_500_errors</span> <span class="keyword">end</span></code></pre></div> <ul> <li>Lighttpd <ul> <li>Better FCGI support</li> <li>More stable</li> </ul></li> <li>Switched to standalone, external FCGIs with capistrano spinner/spawner/reaper tasks, and finally got stable.</li> </ul> <h2>Tuning</h2> <ul> <li>Cache, cache, cache</li> <li>Got RAM?</li> <li>Hot spot/profiling/benchmarking</li> <li>Use httperf not ab</li> <li>See Zed Shaw&#8217;s rant on statistics (<a href="http://www.zedshaw.com/blog/programming/programmer_stats.html">Programmers Need To Learn Statistics Or I Will Kill Them All</a>)</li> </ul> <h2>Shared hosting</h2> <ul> <li>Apache with ProxyPass/ProxyPassReverse talking to multiple lighty instances is about as good as it gets.</li> <li>But let&#8217;s face it&#8230;shared hosting + Rails suck.</li> <li>Only as reliable as the worst application on the server</li> <li>Not always good neighbors</li> <li>Resource constraints</li> <li>Free-for-all</li> </ul> <p>Ezra recommends a Xen VPS for Rails deployment. I&#8217;ve followed his advice; this blog is hosted on a Xen VPS at <a href="http://rimuhosting.com">http://rimuhosting.com</a>.</p> <h2>Deployment models</h2> <ul> <li>Starting point, web, app and db on the same server.</li> <li>Next, move database to a separate server. Use the more powerful hardware to the db.</li> <li>Third, split each role to a separate server. But now you need an NFS to serve static and cached contents. Ezra states you can go a long way with this setup</li> </ul> <div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">class </span><span class="class">FutureOfRailsDeployment</span> <span class="punct">&lt;</span> <span class="constant">ActiveRecord</span><span class="punct">::</span><span class="constant">Base</span> <span class="ident">belongs_to</span> <span class="symbol">:mongrel</span> <span class="keyword">end</span></code></pre></div> <h2>Mongrel</h2> <ul> <li>Speaks plain old HTTP, so you can take advantage of existing tools for load balancing, proxying or caching</li> <li>You can use frontends: Pound, Pen, Balance, Haproxy, Lighttpd (although mod_proxy needs to be fixed), or Apache 2.2 mod<em>proxy</em>balancer</li> <li>Mongrel cluster gem allows easy management of multiple mongrel processes. It&#8217;s straightforward to integrate with capistrano too.</li> </ul> <h2>Engine Yard</h2> <p>Ezra describes a new hosting service he&#8217;s been working on that will give you a greatly simplified but powerful and performant hosting environment for your Rails applications, including a web admin console and deployment directly from SVN revisions and tags.</p> <p>Go to <a href="http://engineyard.com/">Engine Yard</a> for a beta signup email now!</p> <h2>BackgroundDrb</h2> <ul> <li>Distributed Ruby server that manages long runnng tasks.</li> <li>Uses a <code>MiddleMan</code> proxy/stub class that allows the Rails process to connect to the background server.</li> <li>Can use it as a worker queue, (e.g. for sending email) or as a distributed memory cache.</li> <li>You can even query for progress on the background workers and push the result all the way to the browser with an ajax progress bar.</li> <li>The code for BackgroundDrb looks really clean! Go to <a href="http://backgroundrb.rubyforge.org/">http://backgroundrb.rubyforge.org/</a> for the nitty gritty.</li> </ul> Sat, 24 Jun 2006 19:18:00 +0000 urn:uuid:8f4d5e50-85e2-40a8-9038-2b69d1b74322 Nick Sieger http://blog.nicksieger.com/articles/2006/06/24/railsconf-ezra-rails-deployment ruby rails railsconf http://blog.nicksieger.com/articles/trackback/29