<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Motion Standing Still &#187; Performance Project</title>
	<atom:link href="http://www.motionstandingstill.com/category/performance-project/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.motionstandingstill.com</link>
	<description>high performance ruby on rails</description>
	<lastBuildDate>Sun, 11 Jul 2010 03:46:07 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Nginx to send files with x-accel-redirect</title>
		<link>http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/</link>
		<comments>http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 02:06:05 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Nginx File Transfers]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[mimetype]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[sendfile]]></category>
		<category><![CDATA[x-accel-redirect]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=109</guid>
		<description><![CDATA[So far I&#8217;ve configured Nginx to handle file uploads by caching the file to disk and telling rails where it is, rather than passing it through in the request, not fun with large files.  Now to do the reverse.  Instead of Rails sending files to users thru Nginx, Rails can tell Nginx what file to [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">So far I&#8217;ve configured Nginx to handle file uploads by caching the file to disk and telling rails where it is, rather than passing it through in the request, not fun with large files.  Now to do the reverse.  Instead of Rails sending files to users thru Nginx, Rails can tell Nginx what file to send.</p>
<p style="text-align: justify;">I&#8217;d initially assumed that when a Rails application (lets say <a href="http://mongrel.rubyforge.org/" target="_blank">Mongrel</a>) was sending a file with the &#8217;send_file&#8217; method then it couldn&#8217;t handle other requests as they came in.  Seeing as that was an assumption rather than fact I setup a download action on my Ubuntu dev server to show this happening.  Basically a website supported by a single Mongrel &#8211; if it&#8217;s busy sending a large file additional requests will get queued up eventually giving 503 errors I figured as they timed out.</p>
<p style="text-align: justify;">I set the action going to download a 40mb test file on the server, opened up another tab and loaded another test page and it appear straight away.  So my assumption was wrong, but not completely wrong it turns out.  Mongrel is still sending the file though as if I kill it the download terminates.  This is because Mongrel has it&#8217;s own internal request queue and only sends one request at a time to your Rails code. Hence the ability to handle additional requests while someone is downloading a file and websites running <a href="http://mongrel.rubyforge.org/wiki/MongrelCluster" target="_blank" class="broken_link">clusters of Mongrels</a>.  Getting Mongrel to send the file isn&#8217;t the best use of resources though.</p>
<p style="text-align: justify;">For Nginx to send files on Mongrel&#8217;s behalf two changes are needed.  Firstly you need to tell Nginx that it should be doing this and from where.  The Nginx <a href="http://wiki.codemongers.com/NginxXSendfile" target="_blank">sendfile</a> page is quite helpful in this regard, you&#8217;ll end up having something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">location <span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  internal;
  root
<span style="color: #000000; font-weight: bold;">/</span>;  <span style="color: #666666; font-style: italic;"># note the trailing slash</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p style="text-align: justify;">Note, sendfile is enabled by default in all nginx.conf files I&#8217;ve seen.</p>
<p style="text-align: justify;">Secondly, in your Rails download action do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">if</span>
  head<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:x_accel_redirect</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;/files/#{filename}&quot;</span>,  <span style="color:#ff3333; font-weight:bold;">:content_type</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">mime_type</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:content_disposition</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;attachment; filename=#{filename}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">else</span>
  send_file<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{RAILS_ROOT}/files/#{filename}&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:type</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">mime_type</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p style="text-align: justify;">It is important that you specify the correct mime_type to stop the receiving browser guessing and potentially changing the file extension.  If one of the standard rails attachment gems is being used, then you&#8217;ll likely have that information already.  But if you don&#8217;t, like in the example above, then <a href="http://github.com/mattetti/mimetype-fu" target="_blank">mimetype</a>_fu is a very handy plugin as it extends the File class by adding the mime_type? method.</p>
<p style="text-align: justify;">If you store files with guid like names, then the file name received by the user can be controlled by changing the :content_disposition value.</p>
<p style="text-align: justify;">Finally, the reason I&#8217;ve specified the source tree root is so that files from multiple top level folders can be accessed from the one location entry in the Nginx config.</p>
<p style="text-align: justify;">There is a plugin somewhere that does the head changes for you, but it&#8217;s been abandoned and even has a message suggesting that it shouldn&#8217;t be used for that very reason.  I&#8217;ve not used it for that reason and because it assumes all file downloads are to be handled by Nginx.  That&#8217;s a nasty assumption that would bite someone one day, so not very fun.  So I&#8217;m in the process of rolling my own.</p>
<p style="text-align: justify;">Apache can do the same with with <a href="http://www.google.co.nz/search?q=apache+ruby+on+rails+mod_xsendfile" target="_self">mod_xsendfile</a>.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/using-nginx-to-send-files-with-x-accel-redirect/2008-09-03/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Amazon Elastic Block Store (EBS)</title>
		<link>http://www.motionstandingstill.com/amazon-elastic-block-store-ebs/2008-08-23/</link>
		<comments>http://www.motionstandingstill.com/amazon-elastic-block-store-ebs/2008-08-23/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 09:52:02 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Performance Project]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[ebs]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[high availability]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=90</guid>
		<description><![CDATA[Amazon&#8217;s persistent storage beta program for Elastic Cloud Computing (EC2) has been unleashed on the general public.  I&#8217;ve been hanging out to play with this for a while and will duplicate any tests I perform on Slicehost servers with comparable EC2 servers with EBS.  Since I&#8217;m also essentially comparing two different providers, I&#8217;ll look at [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Amazon&#8217;s<a href="http://www.amazon.com/gp/browse.html/ref=pe_2170_10160930?node=689343011" target="_blank"> persistent storage</a> beta program for Elastic Cloud Computing (EC2) has been unleashed on the general public.  I&#8217;ve been hanging out to play with this for a while and will duplicate any tests I perform on Slicehost servers with comparable EC2 servers with EBS.  Since I&#8217;m also essentially comparing two different providers, I&#8217;ll look at the costs.</p>
<p style="text-align: justify;">The page I&#8217;ve linked to above is worth reading as it covers performance and durability quite succinctly.  It&#8217;s pretty awesome to learn that you can just treat each block (EBS) as you would traditional physical storage, striping multiple mounts to achieve greater performance.  Hurrah!  Given the only different in cost of having three 30gb blocks striped compared to a single 30gb block would be three times the access costs I wonder if this would be the more common style of configuration?  I also wonder how backups / snapshots work in this situation as synchronization would be quite important one would think.</p>
<p style="text-align: justify;">I find sometimes it&#8217;s the case that numbers quoted by a merchant aren&#8217;t often attained in the real world as they only reflect usage under ideal conditions.  Internet speeds in New Zealand, pictures of fast food and cosmetic benefits being good examples.  So I wonder if the same will apply to this new service?  Time will tell and I&#8217;m sure it&#8217;ll be big news if Amazon&#8217;s <em>numbers</em> are considerably off the mark.</p>
<p style="text-align: justify;">Come to think of it I don&#8217;t know how Amazon&#8217;s existing services stack up against what is advertised.  I&#8217;m gonna find out though as I intend to see how much I can squeeze out of their service too.  Apart from the geek factor, I&#8217;m doing this as clients are increasingly asking about Amazon EC2 after I normally recommend either Slicehost or a dedicated box somewhere.  Basically at the moment I don&#8217;t know, when I need to know.</p>
<p style="text-align: justify;">So I have four big questions around using Amazon EC2.  Firstly a big cause of concern for me is their service having already experienced<a href="http://www.google.co.nz/search?q=amazon+downtime+ec2" target="_blank"> a number of notable down times</a> including what appears to be reported data loss.  With their latest significant event Amazon has been very open about the problem and what they are doing as a result &#8211; nice and positive.  Although, as nice as that is, they should really stop having them.</p>
<p style="text-align: justify;">Secondly is performance, obviously.  I&#8217;m gonna put everything that can&#8217;t be replicated on EBS, including all logs that interest me.  Of note, I&#8217;ll have a webserver, a load balancer and many many application instance continuously logging away from multiple servers and having a good time about it.  Oh and also the database.  Performance better not blink.  Previously a big turn off for me has been the situation of &#8216;what logs?&#8217; -  if an EC2 server suddenly stops, you have no way of knowing what just happened.  Yeah I know about services like <a href="http://www.rightscale.com">RightScale</a> that attempt to minimize this, but its not good enough by my standards.  Plus their sign-up fee is a big turn off to me, presumably they are trying to protect their IP from free access.  Anyway, who does big sign-up fees anymore???  It&#8217;s so 2005.</p>
<p style="text-align: justify;">
<p style="text-align: justify;">Thirdly is unexpected restarts.  What event based actions can I automate?  I don&#8217;t know and this is possibly just because I&#8217;ve not dug into it deep enough yet.  When they restart, EC2 servers are blank again.  Can I set them to be automatically loaded with a script which reverts their state back to what it was pre-reboot?  I doubt this would be as quick as I&#8217;d want so I could just symlink most of the OS to EBS &#8211; depending on it&#8217;s performance.  It implies that either Amazon provides a harness that sits around all your servers for kicking off the scripts as needed, or you use a third party or you roll your own.  I&#8217;ve been looking out for an excuse to setup a big kickass <a href="http://en.wikipedia.org/wiki/High_availability" target="_blank">high availibilty</a> setup, then it wouldn&#8217;t matter!  Hmmmm.</p>
<p style="text-align: justify;">UPDATE: You can mount EBS as the file system on EC2 as noted <a href="http://aws.typepad.com/aws/2008/08/amazon-elastic.html" target="_blank">here</a>.  That basically implies it&#8217;s up there in the performance stakes and obviously no need to reinstall everything after a reboot.  You can also create a new EBS from a snapshot which is extremely handy.</p>
<p style="text-align: justify;">Forthly, permanent ip addresses &#8211; I know they have them but again that&#8217;s about the limit of my knowledge.  The lack of an EBS like service has stopped me seriously investigating AWS until now.  Can I have more than one ip address per server?  Can I have a floating one if I want to roll my own my high availability configuration?</p>
<p style="text-align: justify;">Backing up user content and other important data is a really big deal for a website, especially as it starts accumulating and accumulating.  I have found Amazon S3 is my best mate for this &#8211; especially for doing regular rsync like backups.  If a website is entirely hosted with EC2 and EBS this becomes a whole lot easier to the point of being stupidly easy.  That unto itself is a really big deal.</p>
<p style="text-align: justify;">At the moment all server oriented virtualized services that I can recall using and reading about are essentially just replications of physical devices &#8211; normally with marginally lower performance characteristics while being more reliable due to their redundant nature.  I do wonder though when someone will come up with something new that&#8217;s not available in the physical world and what that will be.</p>
<p style="text-align: justify;">Aside from the concerns I&#8217;ve expressed above, I&#8217;ll just add that what an awesome learning tool AWS and like services are becoming.  Who cares if you screw up &#8211; learn, wipe and start again.</p>
<p style="text-align: justify;">I&#8217;ve got even more geeking out ahead of me now, sweet.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/amazon-elastic-block-store-ebs/2008-08-23/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Finishing off my base Ruby on Rails install</title>
		<link>http://www.motionstandingstill.com/finishing-off-my-base-ruby-on-rails-install/2008-08-07/</link>
		<comments>http://www.motionstandingstill.com/finishing-off-my-base-ruby-on-rails-install/2008-08-07/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 00:37:24 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Performance Project]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[production log analyzer]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=66</guid>
		<description><![CDATA[So I got sidetracked with Apache in my last post.  Here I&#8217;m going to finish up the install basics sans automated deployment.  At the moment I&#8217;m just jumping onto the server and going:

git pull
mongrel_rails cluster::restart

All my server is showing at the moment is this.  It&#8217;s amazing I know and people will talk about it for [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>So I got sidetracked with Apache in my last post.  Here I&#8217;m going to finish up the install basics sans automated deployment.  At the moment I&#8217;m just jumping onto the server and going:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git pull
mongrel_rails cluster::restart</pre></div></div>

<p>All my server is showing at the moment is <a href="http://small.nahumwild.com" target="_blank" class="broken_link">this</a>.  It&#8217;s amazing I know and people will talk about it for years to come.  Probably get a couple of book deals out of it too I expect.</p>
<p>Basically, I don&#8217;t have anything else to put there at present.  I have two website ideas under consideration though, and a third thought of moving this blog to my own server as it&#8217;s not particularly speedy here at Dreamhost.  You get what you pay for though&#8230;and I&#8217;m not paying much.  Dreamhost are good, don&#8217;t get me wrong on that.</p>
<p>Ideally I&#8217;d want to use some Ruby on Rails blogging software but a quick google doesn&#8217;t turn anything <a href="http://www.merriam-webster.com/dictionary/awesome" target="_blank">awesome</a> up.  I&#8217;d probably have to reproduce all the extra plugins I&#8217;m using etc, so I likely be sticking with WordPress for the time being.</p>
<p>Anyway, I&#8217;ve got Apache installed and configured with a really bare bones script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">NameVirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span>
&nbsp;
ServerName <span style="color: #000000; font-weight: bold;">&lt;</span>your_domain_name<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span>
  ServerName <span style="color: #000000; font-weight: bold;">&lt;</span>your_domain_name<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
  DocumentRoot <span style="color: #000000; font-weight: bold;">&lt;</span>your_code_path<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #ff0000;">&quot;&lt;your_code_path&gt;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  <span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span> 
&nbsp;
  Alias <span style="color: #000000; font-weight: bold;">/</span>images <span style="color: #000000; font-weight: bold;">&lt;</span>your_code_path<span style="color: #000000; font-weight: bold;">&gt;/</span>public<span style="color: #000000; font-weight: bold;">/</span>images
  Alias <span style="color: #000000; font-weight: bold;">/</span>stylesheets <span style="color: #000000; font-weight: bold;">&lt;</span>your_code_path<span style="color: #000000; font-weight: bold;">&gt;/</span>stylesheets 
  Alias <span style="color: #000000; font-weight: bold;">/</span>javascripts <span style="color: #000000; font-weight: bold;">&lt;</span>your_code_path<span style="color: #000000; font-weight: bold;">&gt;/</span>javascripts
&nbsp;
  ProxyPass <span style="color: #000000; font-weight: bold;">/</span>images <span style="color: #000000; font-weight: bold;">!</span> 
  ProxyPass <span style="color: #000000; font-weight: bold;">/</span>stylesheets <span style="color: #000000; font-weight: bold;">!</span>  
  ProxyPass <span style="color: #000000; font-weight: bold;">/</span>javascripts <span style="color: #000000; font-weight: bold;">!</span>  
&nbsp;
  <span style="color: #666666; font-style: italic;"># Check for maintenance file and redirect all requests</span>
  <span style="color: #666666; font-style: italic;">#  ( this is for use with Capistrano's disable_web task )</span>
  RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>REQUEST_URI<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>\.<span style="color: #7a0874; font-weight: bold;">&#40;</span>css<span style="color: #000000; font-weight: bold;">|</span>jpg<span style="color: #000000; font-weight: bold;">|</span>png<span style="color: #000000; font-weight: bold;">|</span>htc<span style="color: #000000; font-weight: bold;">|</span>gif<span style="color: #7a0874; font-weight: bold;">&#41;</span>$
  RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>DOCUMENT_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>maintenance.html <span style="color: #660033;">-f</span>
  RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>SCRIPT_FILENAME<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>maintenance.html
  RewriteRule ^.<span style="color: #000000; font-weight: bold;">*</span>$ <span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>maintenance.html <span style="color: #7a0874; font-weight: bold;">&#91;</span>L<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># re-write so that all non-static requests go to the cluster</span>
  RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>DOCUMENT_ROOT<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>REQUEST_FILENAME<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>-f
  RewriteRule ^<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>$ balancer:<span style="color: #000000; font-weight: bold;">//</span>mongrel_clusters<span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>REQUEST_URI<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>P,QSA,L<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>Proxy balancer:<span style="color: #000000; font-weight: bold;">//</span>mongrel_clusters<span style="color: #000000; font-weight: bold;">&gt;</span>
  BalancerMember http:<span style="color: #000000; font-weight: bold;">//</span>localhost:<span style="color: #000000;">1234</span>
  BalancerMember http:<span style="color: #000000; font-weight: bold;">//</span>localhost:<span style="color: #000000;">1235</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>Proxy<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>It&#8217;s fairly basic, if the requested file isn&#8217;t found on disk pass it off to the mongrel cluster, oh and don&#8217;t ever ask mongrel for a javascript, stylesheet or image file.</p>
<p>Obviously this requires that I have mongrel installed:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> mongrel_cluster</pre></div></div>

<p>As indicated above I&#8217;ve already gotten the source code where I want it on the server, I&#8217;ve stubbed out a bit of the <a href="http://www.capify.org/" target="_blank">Capistrano</a> style directory structure.  So now I can just run my cluster of two mongrels and all just works fine and dandy.</p>
<p>Next up I&#8217;ve got to create a good page for benchmarking against, and then do just that before I start upgrading the configuration and code to make it super fast.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/finishing-off-my-base-ruby-on-rails-install/2008-08-07/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Configuring and watching Apache.</title>
		<link>http://www.motionstandingstill.com/configuring-and-watching-apache/2008-08-03/</link>
		<comments>http://www.motionstandingstill.com/configuring-and-watching-apache/2008-08-03/#comments</comments>
		<pubDate>Sun, 03 Aug 2008 06:09:06 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Performance Project]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache mpm event]]></category>
		<category><![CDATA[apache mpm prefork]]></category>
		<category><![CDATA[apache mpm worker]]></category>
		<category><![CDATA[apache2ctl]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[mod_info]]></category>
		<category><![CDATA[mod_status]]></category>
		<category><![CDATA[virtualhost]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=49</guid>
		<description><![CDATA[You may have noted that I installed the apache2-mpm-worker package rather than apache2-mpm-prefork even though I&#8217;m using a VPS to host the site.  If you google them you&#8217;ll find recommendations to only use worker on big beefed-up servers.  The reason for my decision is described in the first paragraph on worker&#8217;s webpage:
By using threads to [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>You may have noted that <a href="/apache-it-works/2008-07-17/" target="_blank">I installed</a> the <a href="http://httpd.apache.org/docs/2.2/mod/worker.html" target="_blank">apache2-mpm-worker</a> package rather than <a href="http://httpd.apache.org/docs/2.2/mod/prefork.html" target="_blank">apache2-mpm-prefork</a> even though I&#8217;m using a <a href="http://en.wikipedia.org/wiki/Virtual_private_server" target="_blank">VPS</a> to host the site.  If you google them you&#8217;ll find recommendations to only use worker on big beefed-up servers.  The reason for my decision is described in the first paragraph on worker&#8217;s webpage:</p>
<blockquote><p>By using threads to serve     requests, it is able to serve a large number of requests with     fewer system resources than a process-based server.</p></blockquote>
<p>Sounded good to me when I first read about it.  My experience with both worker and pre-fork has shown this to be very true, in particular the improved resource usage &#8211; hence my choice for with my <a href="http://www.slicehost.com/" target="_blank">256mb slice</a>.</p>
<p>I&#8217;ve not used the newer, and shouldn&#8217;t be used for production, <a href="http://httpd.apache.org/docs/2.2/mod/event.html" target="_blank">Apache MPM event</a>.  I do plan to read up more about it and then give it a whirl at some point though.</p>
<p>I had been using the following command to start and stop Apache, but found it to be woefully limiting:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2
<span style="color: #000000; font-weight: bold;">*</span> Usage: <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #7a0874; font-weight: bold;">&#123;</span>start<span style="color: #000000; font-weight: bold;">|</span>stop<span style="color: #000000; font-weight: bold;">|</span>restart<span style="color: #000000; font-weight: bold;">|</span>reload<span style="color: #000000; font-weight: bold;">|</span>force-reload<span style="color: #000000; font-weight: bold;">|</span>start-htcacheclean<span style="color: #000000; font-weight: bold;">|</span>stop-htcacheclean<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Instead I&#8217;m now using the alternative that I went looking for:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2ctl
<span style="color: #000000; font-weight: bold;">*</span> Usage: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2ctl <span style="color: #7a0874; font-weight: bold;">&#123;</span>start<span style="color: #000000; font-weight: bold;">|</span>stop<span style="color: #000000; font-weight: bold;">|</span>restart<span style="color: #000000; font-weight: bold;">|</span>graceful<span style="color: #000000; font-weight: bold;">|</span>graceful-stop<span style="color: #000000; font-weight: bold;">|</span>configtest<span style="color: #000000; font-weight: bold;">|</span>status<span style="color: #000000; font-weight: bold;">|</span>fullstatus<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Which as you can see actually has the <em>status</em> command!  Why this isn&#8217;t in the /etc/init.d based script I don&#8217;t know.  Maybe I&#8217;m shouldn&#8217;t be controlling Apache through init.d, but lots of others seem to be&#8230;  Anyway as well as the <em>status</em> command I was lacking the <a href="http://httpd.apache.org/docs/2.2/stopping.html#graceful" target="_blank">graceful</a> command which I find invaluable.</p>
<p>Both the /etc/init.d/apache2 and /usr/sbin/apache2ctl scripts are compatible with each other as the former just calls the latter.</p>
<p>Mod_status is required for the <em>status</em> command to work, which is fine until I install my rails app as it will respond to <em>/server-status</em> instead.  As a result I&#8217;ve reconfigured mod_status to run on a different port and while there I setup mod_info too.  I obviously had to punch a new hole through the firewall so I could access this off-server.</p>
<p>Finally if you get the following error when starting and stopping your Apache server:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName</pre></div></div>

<p>You need to define <em>ServerName</em> somewhere in addition to within a <em>virtualhost</em> area.  This is dicussed <a href="Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName" target="_blank" class="broken_link">here</a>.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/configuring-and-watching-apache/2008-08-03/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RubyGems needs 512 to upgrade itself.</title>
		<link>http://www.motionstandingstill.com/rubygems-needs-512-to-upgrade-itself/2008-07-28/</link>
		<comments>http://www.motionstandingstill.com/rubygems-needs-512-to-upgrade-itself/2008-07-28/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 10:10:40 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Performance Project]]></category>
		<category><![CDATA[boot process]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[passphrase]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=33</guid>
		<description><![CDATA[After watching a rather sloppy rugby game in which the All Blacks couldn&#8217;t hold onto a ball to save themselves I jumped back online to find my gem updating process was still using lots of memory and no cpu.  After being amused by the comparison to the rugby game I killed it and got slicehost [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>After watching a rather sloppy rugby game in which the All Blacks couldn&#8217;t hold onto a ball to save themselves I jumped back online to find my gem updating process was still using lots of memory and no cpu.  After being amused by the comparison to the rugby game I killed it and got slicehost to resize the server up to 512mb of ram.  Updating <a href="http://docs.rubygems.org/" target="_blank">RubyGems</a> then worked a treat.</p>
<p>The one thing to note here is that by running the automated self update, RubyGems effectively downloads the source to the latest version and compiles and distributes it onto the server.  This breaks my previously mentioned rule of <strong>don&#8217;t compile source</strong>, but in this case I have no choice as this is how RubyGems works.</p>
<p>Since this leaves me with two seperate installations, the apt-get package and the compiled version I then uninstalled the package.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> remove rubygems libgems-ruby1.8</pre></div></div>

<p>Before I downgraded back to a 256mb server, ie while I still had twice the grunt, I installed Ruby on Rails.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</pre></div></div>

<p>Noting I&#8217;m still logged in as root at this stage so I don&#8217;t need to pre-fix the above command with <a href="http://linux.about.com/od/commands/l/blcmdl8_sudo.htm" target="_blank">sudo</a>.</p>
<p>Next up, <a href="http://dev.mysql.com/" target="_blank">MySQL</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql-server mysql-client libmysqlclient15-dev</pre></div></div>

<p>You&#8217;ll get asked for root&#8217;s password as part of the package&#8217;s installation process.  Do use one and don&#8217;t loose it.  I use <a href="http://en.wikipedia.org/wiki/Passphrase" target="_blank">passphrases</a> rather than passwords as they&#8217;re way more secure and I can easily memorise them.</p>
<p>Following this I then logged into MySQL and created the main database, and while I was there I setup the <em>rails</em> user account.  As you can see I&#8217;m being pretty liberal with the access rights at this stage.  That&#8217;ll change though.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> performance_prod;
<span style="color: #993333; font-weight: bold;">CREATE</span> USER <span style="color: #ff0000;">'rails'</span>@<span style="color: #ff0000;">'localhost'</span> <span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">'some_passwphrase'</span>;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">ALL</span> PRIVILEGES <span style="color: #993333; font-weight: bold;">ON</span> performance_prod<span style="color: #66cc66;">.*</span> <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #ff0000;">'rails'</span>@<span style="color: #ff0000;">'localhost'</span>;</pre></div></div>

<p>At this stage I&#8217;m using the vanilla MySQL config meaning the database will only respond to requests from localhost.  I&#8217;ve infact not looked at the default MySQL config for Ubuntu yet, but if it&#8217;s anything like the default one on CentOS it&#8217;ll be getting some love real quick.  That one assumes you only have something like 16mb of ram for the whole system!  Changing it makes a big difference.</p>
<p>As I&#8217;ll be wanting my rails app to talk to MySQL I&#8217;ll be needing the API module that allows this.  Under CentOS and OSX this is a gem that can be particullarly annoying to install, especially under OSX.  Thankfully someone has kindly packaged it up for us.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libmysql-ruby</pre></div></div>

<p>As an aside, I bumped into this article listing <a href="http://blogs.techrepublic.com.com/10things/?p=387" target="_blank">ten ways to make linux boot faster</a> and pretty much ignored them all except for the final point.  Tried it and it appears to work a treat.  Edit /etc/init.d/rc and change the following setting to:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">CONCURRENCY</span>=shell</pre></div></div>



<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/rubygems-needs-512-to-upgrade-itself/2008-07-28/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trouble upgrading rubygems.</title>
		<link>http://www.motionstandingstill.com/trouble-upgrading-rubygems/2008-07-26/</link>
		<comments>http://www.motionstandingstill.com/trouble-upgrading-rubygems/2008-07-26/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 09:49:54 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Performance Project]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygems]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=26</guid>
		<description><![CDATA[A little more fiddling and I discovered that when I installed vim-full an incomplete install of ruby 1.8 was also placed on the system.  Aptitude thought ruby was installed, but it wasn&#8217;t.  Hence two posts ago me saying that Ubuntu was weird and I had to reinstall ruby.
A second problem with what I installed was [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>A little more fiddling and I discovered that when I installed <em>vim-full</em> an incomplete install of ruby 1.8 was also placed on the system.  Aptitude thought ruby was installed, but it wasn&#8217;t.  Hence <a href="http://www.motionstandingstill.com/apache-it-works/2008-07-17/" target="_blank">two posts ago</a> me saying that Ubuntu was weird and I had to reinstall ruby.</p>
<p>A second problem with what I installed was that the command &#8216;ruby -v&#8217; wouldn&#8217;t work but &#8216;ruby1.8 -v&#8217; would give the desired result.  Ruby had been installed everywhere prefixed with &#8216;1.8&#8242;.  Makes sense as it allows you to have multiple versions of ruby installed at once, but things like mongrel won&#8217;t work as they are expecting to find &#8216;ruby&#8217; not &#8216;ruby1.8&#8242;.  Meaning I&#8217;d have to create a bunch of symbolic links like below to solve the problem.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-snf</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby</pre></div></div>

<p>I don&#8217;t like that as it&#8217;s fails the <strong>don&#8217;t compile source</strong> rule as the moment I upgrade to ruby 1.9 I&#8217;ve got to remember to manually change all those symbolic links.  A bit more digging and I discovered that there are packages that do this for me, so in the end I&#8217;ve run the following to install ruby on Ubuntu:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ruby libruby irb ruby1.8-dev libopenssl-ruby libreadline-ruby ri rdoc</pre></div></div>

<p>Package dependencies mean that all the previous packages I was trying to install are also installed.  Nice.</p>
<p>Next up <a href="http://docs.rubygems.org/" target="_blank">RubyGems</a>.  RubyGems uses the yaml and zlib libraries, as noted <a href="http://docs.rubygems.org/read/chapter/3#page13" target="_blank">here</a>,  but it&#8217;s package unfortunately hasn&#8217;t had this included in it&#8217;s setup, so the following is required for an install:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> rubygems libyaml-ruby libzlib-ruby</pre></div></div>

<p>This only installs version 0.9.4-4 though so you have to run the self update task:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem update <span style="color: #660033;">--system</span></pre></div></div>

<p>Should be pretty simple, but thirty minutes after running this it&#8217;s still only telling me the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Updating RubyGems...
Bulk updating Gem <span style="color: #7a0874; font-weight: bold;">source</span> index <span style="color: #000000; font-weight: bold;">for</span>: http:<span style="color: #000000; font-weight: bold;">//</span>gems.rubyforge.org</pre></div></div>

<p>A quick google revels that this can happen in virtualised systems (ie zen which slicehost use) when you don&#8217;t give them enough system resource.  My server only has 256mb of ram and the <em>gem</em> process quickly ate 85% of it then stopped doing anything.</p>
<p>I might leave it running while I go watch the rugby.  If it&#8217;s still essentially hung after the match I&#8217;ll probably upgrade the server to a 512 instance and try again.  Then upon success, hopefully, I&#8217;ll downgrade back to 256.  Obviously in a real life produciton environment this wouldn&#8217;t be an acceptable practice, but then i wouldn&#8217;t be using a server with 256mb of ram either.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/trouble-upgrading-rubygems/2008-07-26/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why not passenger / mod_rails?</title>
		<link>http://www.motionstandingstill.com/why-not-passenger-mod_rails/2008-07-22/</link>
		<comments>http://www.motionstandingstill.com/why-not-passenger-mod_rails/2008-07-22/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 22:10:23 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Performance Project]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[infrastructure]]></category>
		<category><![CDATA[load balance]]></category>
		<category><![CDATA[mod_rails]]></category>
		<category><![CDATA[ruby enterprise edition]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=19</guid>
		<description><![CDATA[While I was holidaying over the weekend I received an interesting question via email, something along the lines of:
Can you give me a quick overview on what the trouble was running passeneger/enterprise ruby over multiple servers?  I&#8217;m half way through setting up our infrastructure with 1 load balancer passing on to 2 web servers&#8230;  running [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>While I was holidaying over the weekend I received an interesting question via email, something along the lines of:</p>
<blockquote><p>Can you give me a quick overview on what the trouble was running passeneger/enterprise ruby over multiple servers?  I&#8217;m half way through setting up our infrastructure with 1 load balancer passing on to 2 web servers&#8230;  running passenger/enterprise ruby.</p></blockquote>
<p>The short answer is that there isn&#8217;t any problem &#8211; if you&#8217;re running Apache on each of your application servers.  I just don&#8217;t.</p>
<p>After an exchange of emails I learned that they are using the infrastructure provided for the contract being worked on, which isn&#8217;t necessarily their preferred choice.</p>
<p>The reason I haven&#8217;t followed the above paradigm is that Apache (or any hardened webserver) can handle several orders of magnitude more requests a second than what your average Ruby on Rails application can on the same hardware.  Say one Apache to one hundred mongrels, without being very scientific about it.  So why hamstring Apache to the lowest common dominator?  Given each instance of Apache has a minimum footprint, it&#8217;s a waste of resource.  Yes Apache also handles static files from disk that your app will never see, that still doesn&#8217;t change the equation much though.</p>
<p>Think of it this way, database servers get their own box early on, same concept.  Separate out the slowest beast into it&#8217;s own replicable box and just scale out from there as needed.  App servers should just have your application on them.  If you have more traffic than one Apache can handle, then you&#8217;ll obviously want to load balance to multiple web servers.</p>
<p>I&#8217;ve been stuck with a similar infrastructure hurdle before, in my case it was a hardware load balancer which the provider had setup stupidly.  It took them 4 days and two reboots to get it as I wanted it.  Extremely frustrating, especially as the reboots caused site downtime which I like to keep to a minimum.</p>
<p>For this <a href="http://www.motionstandingstill.com/category/performance-project/" target="_blank">project</a> my intention is to performance test the updated configuration after each change and roll back when there isn&#8217;t a benefit.  I&#8217;m not going to have a hardware load balancer so I can&#8217;t really replicate the above, but I could pretend with three servers&#8230;</p>
<p>Anyway, I&#8217;m back online from relaxing over the weekend and sorting out what version and edition of ruby I&#8217;ll be using for my starting point.  After that I need to finish setting up the server for delivering a Ruby on Rails application and then actually create an application for deployment.  I&#8217;m open to suggestions.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/why-not-passenger-mod_rails/2008-07-22/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache, It Works!</title>
		<link>http://www.motionstandingstill.com/apache-it-works/2008-07-17/</link>
		<comments>http://www.motionstandingstill.com/apache-it-works/2008-07-17/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 01:01:26 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Performance Project]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[aptitude]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[mod_rails]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby enterprise edition]]></category>
		<category><![CDATA[slicehost]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=18</guid>
		<description><![CDATA[I was looking through the slicehost article section the other night and bumped into an awesome article on initial configuration steps for ubuntu.  If you don&#8217;t know what your doing, you should go take a look at that.
So, anyway.  I&#8217;ve got a server up and going doing absolutely nothing, and I&#8217;m assuming you do too [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I was looking through the <a href="http://articles.slicehost.com/" target="_blank">slicehost article section</a> the other night and bumped into an <a href="http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-page-1" target="_blank">awesome article</a> on initial configuration steps for <a href="http://www.ubuntu.com" target="_blank">ubuntu</a>.  If you don&#8217;t know what your doing, you should go take a look at that.</p>
<p>So, anyway.  I&#8217;ve got a server up and going doing absolutely nothing, and I&#8217;m assuming you do too at this point.  It&#8217;s just waiting for me to begin steaming on ahead with the initial production stack I&#8217;m <a href="http://www.motionstandingstill.com/the-plan/2008-07-13/" target="_blank">planning on using first</a>.</p>
<p>Lets get Apache on there for some instant gratification:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2 apache2-doc apache2-mpm-worker apache2-utils apache2.2-common libapr1 libaprutil1 libpq5 libexpat1 ssl-cert</pre></div></div>

<p>That&#8217;s all you&#8217;ll need, the <em>ssl-cert</em> package is there so that people can do things over <em>https://</em> with your website like logging in, buying things etc&#8230;.  Provided you&#8217;ve created a port 80 hole in your firewall you should be able to go have a look at the default page once you&#8217;ve made sure apache is up and running.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 force-reload</pre></div></div>

<p>Next I tried getting ruby on there but discovered that it already was, but not really.  It looked like most of it&#8217;s source was, but none of the binaries were, fully weird.  So I uninstalled the base ruby packages:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> remove ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8</pre></div></div>

<p>Then reinstalled everything I thought I&#8217;d need:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby libopenssl-ruby1.8</pre></div></div>

<p>Unfortunately this is Ruby 1.8.6 at patch level 111 (2007-09-24) which has some <a href="http://www.ruby-lang.org/en/news/2008/06/20/arbitrary-code-execution-vulnerabilities/" target="_blank">significant security issues</a> associated with it <a href="http://weblog.rubyonrails.org/2008/6/21/multiple-ruby-security-vulnerabilities" target="_blank">covered last month</a> on the rails weblog.  I was surprised to find that the ubuntu packages havn&#8217;t been updated and that a quick google didn&#8217;t turn up an immediate solution for me apart from <a href="http://www.rubyenterpriseedition.com/" target="_blank">Ruby Enterprise Edition</a>.  I don&#8217;t really want to manually compile it from source and/or apply some back ported patch.</p>
<p>I&#8217;d read that you only gain real advantage from using this fork of ruby when it&#8217;s used in conjunction with <a href="http://www.modrails.com/" target="_blank">mod_rails</a> so I wasn&#8217;t going to bother with it.  I might now though, especially as they appear to have had a quick turn around on this issue.  Additionally I want to quickly move to using Rails 2.1 with Ruby 1.8.7, and again, the ubuntu package was an old build of 1.8.6.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/apache-it-works/2008-07-17/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting the basics done</title>
		<link>http://www.motionstandingstill.com/getting-the-basics-done/2008-07-15/</link>
		<comments>http://www.motionstandingstill.com/getting-the-basics-done/2008-07-15/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 00:38:59 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Performance Project]]></category>
		<category><![CDATA[howtoforge]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[slicehost]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/?p=16</guid>
		<description><![CDATA[So I&#8217;ve setup my SliceHost account and have created a server (the 256mb of ram one for $20 a month).  First off though I needed to the usual house keeping when setting up a new server.
The Centos image at slicehost is bare basic and only comes with openssh, where as the Ubuntu image has a [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve setup my <a href="http://www.slicehost.com/" target="_blank">SliceHost</a> account and have created a server (the 256mb of ram one for $20 a month).  First off though I needed to the usual house keeping when setting up a new server.</p>
<p>The Centos image at slicehost is bare basic and only comes with openssh, where as the Ubuntu image has a bunch of things out of the box which is nice.  The down side of this being that I&#8217;ve got to evaluate and remove the things I don&#8217;t want.  I know what I&#8217;m doing with <a href="http://en.wikipedia.org/wiki/Iptables" target="_blank">iptables</a>, so I don&#8217;t want <a href="http://en.wikipedia.org/wiki/FireHOL" target="_blank">FireHol</a> for example.</p>
<p>Seeing as my blogging on this project isn&#8217;t targeted at how to setup a server from scratch I won&#8217;t bore you with the details of why I use vim and zsh instead of something else and bash etc..  Although I will though throw in a couple of links I found helpful in my transition between distributions which answer my &#8216;err, how do you achieve this in Ubuntu&#8217; and &#8216;where the <a href="http://en.wikipedia.org/wiki/Feck">feck</a> do they put that&#8217; type questions.</p>
<p>As previously mentioned I like to hit up <a href="http://www.howtoforge.com" target="_blank">HowToForge</a> as it&#8217;s a fantastic resource and has served me well for a couple of years now.  On there people like to post instructions on setting up their idea of a &#8216;Perfect Server&#8217;, I&#8217;ve pulled from in a couple of places out of <a href="http://howtoforge.com/perfect-server-ubuntu8.04-lts-p3" target="_blank">this one for instance</a>.  For example, I didn&#8217;t know about FireHOL until reading this.</p>
<p>Additionally the <a href="https://help.ubuntu.com/community" target="_blank">community help/docs</a> portion of the Ubuntu site was quite helpful, in particular the <a href="https://help.ubuntu.com/community/IptablesHowTo" target="_blank">iptables how-to</a> solved my problem of persistence through restarts.  I have just used my base configuration for this and will expand it out as needed.</p>
<p>Next up is actually installing and configuring the main stack.  I&#8217;ll go and find myself a good code formatting wordpress plug first before blogging about that.</p>
<p>On a side note, with my first post on this topic three days ago I mentioned Ponoko.  The post was published less then two hours before Google&#8217;s daily alert digest to me covering the key word of &#8216;Ponoko&#8217;.  My post was in that list, and the same happened for my next post.  I was quite impressed as to how quickly that got picked up considering how inactive my blog has been up until recently.  So I&#8217;ve mentioned Ponoko again. primarily just for the heck of it, and to get the traffic. :-)</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/getting-the-basics-done/2008-07-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Plan.</title>
		<link>http://www.motionstandingstill.com/the-plan/2008-07-13/</link>
		<comments>http://www.motionstandingstill.com/the-plan/2008-07-13/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 00:25:28 +0000</pubDate>
		<dc:creator>nahum</dc:creator>
				<category><![CDATA[Performance Project]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[haproxy]]></category>
		<category><![CDATA[infrastructure]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[load balance]]></category>
		<category><![CDATA[mod_rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[slicehost]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.motionstandingstill.com/2008/07/13/the-plan/</guid>
		<description><![CDATA[As I eluded to yesterday I&#8217;m going down the Ubuntu track and doing this on SliceHost.
Ubuntu, because basically the wealth of resources available online for this distribution is massive compared to the likes of CentOS/RedHat.  Well, the places where I look anyways.  I use SliceHost for hosting Ponoko and couldn&#8217;t praise them more.  For US$20 [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>As I eluded to yesterday I&#8217;m going down the <a href="http://www.ubuntu.com">Ubuntu</a> track and doing this on <a href="http://www.slicehost.com">SliceHost</a>.</p>
<p>Ubuntu, because basically the wealth of resources available online for this distribution is massive compared to the likes of CentOS/RedHat.  Well, the <a href="http://www.howtoforge.com">places where I look</a> anyways.  I use SliceHost for hosting Ponoko and couldn&#8217;t praise them more.  For US$20 a month I get a whole server to myself, persistent storage and fixed ip address &#8211; I can do with it as I wish.  If Amazon AWS persistent storage was publicly available and they didn&#8217;t have spam problems I&#8217;d be considering them.</p>
<p>So the plan is to setup a stack for serving a Ruby on Rails application on a single server, and then to see how much I can squeeze out of it before bring in more servers/slices.  The advantage of doing this as a personal project is that I don&#8217;t have to be massively pragmatic about it &#8211; more of my decisions can be geeky based rather than asking myself &#8216;will this make money&#8217;?</p>
<p>On with the plan.  This is going to be done in stages, the first is just taking what I&#8217;ve previously implemented and moving that to Ubuntu.  Essentially a very traditional stack as follows:</p>
<p>Apache 2.2<br />
Mod_Proxy<br />
MongrelCluster<br />
Ruby 1.8.7<br />
MySQL 5.x<br />
MemCached</p>
<p>Initially going with the above familiar stack allows me to focus my learing on the Ubuntu way of things without the distractions of setting up a new stack.  Additionally I&#8217;ll need to come up with a small set of performance tests to track my progress to prove my assumptions/choices.</p>
<p>Once that&#8217;s done, the intention is to upgrade the stack to the following:</p>
<p>Nginx<br />
HAProxy<br />
Thin<br />
Ruby Enterprise (or something else maybe)<br />
MySQL 5.x<br />
MemCached</p>
<p>Astute readers will note that I&#8217;ve not included <a href="http://www.modrails.com">mod_rails</a> in there.  My intention is for this configuration to become a multi-server setup supporting a fictous site experiencing heaps of traffic.  Mod_rails isn&#8217;t going to help in that situation as it&#8217;s limitied to the server that Apache is on only.  So no point learning about it.</p>
<p>I&#8217;ll be throwing HAProxy in there as it&#8217;s screams while the &#8216;fair&#8217; load balancer for nginx apparently still has subtle problems that would be of concern to a busy live site.  I want a site that can be updated without being taken down and HAProxy will allow me to do this.</p>
<p>The overall goal is a high performant ruby on rails website that can scale as needed while experiencing a minimum of downtime.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.motionstandingstill.com/the-plan/2008-07-13/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 5.149 seconds -->
