<?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>RubyRescue &#187; deployment</title>
	<atom:link href="http://www.rubyrescue.com/blog/category/deployment/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rubyrescue.com/blog</link>
	<description>begin..rescue..end</description>
	<lastBuildDate>Mon, 19 Jul 2010 14:46:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>cat /proc/cpuinfo or Don&#8217;t Trust Your Cores To Rackspace, Part I</title>
		<link>http://www.rubyrescue.com/blog/2009/10/27/cat-proccpuinfo-or-dont-trust-your-cores-to-rackspace-part-i/</link>
		<comments>http://www.rubyrescue.com/blog/2009/10/27/cat-proccpuinfo-or-dont-trust-your-cores-to-rackspace-part-i/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 02:01:48 +0000</pubDate>
		<dc:creator>chad</dc:creator>
				<category><![CDATA[deployment]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[rackspace]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[unicorn]]></category>

		<guid isPermaLink="false">http://www.rubyrescue.com/blog/?p=73</guid>
		<description><![CDATA[We&#8217;ve been running a pretty high traffic site on one big server for more than a year and a half. The site was originally PHP, but about four months ago we migrated the site to Rails. The Rails migration has been relatively smooth, and we now are serving more than 9 sites (mostly branding and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.rubyrescue.com/blog/wp-content/uploads/2009/10/doggiewithwheels.jpg" alt="doggiewithwheels" title="doggiewithwheels" width="468" height="301" class="alignleft size-full wp-image-78" />We&#8217;ve been running a pretty high traffic site on one big server for more than a year and a half. The site was originally PHP, but about four months ago we migrated the site to Rails. The Rails migration has been relatively smooth, and we now are serving more than 9 sites (mostly branding and some content differences between them) on one server.</p>
<p>The server has the whole stack &#8211; Apache, Passenger, MySQL, however once we migrated to Rails we simply had to start thinking about performance in a way we haven&#8217;t before. I&#8217;m not going to argue that this is a reason not to use Rails &#8211; I believe that if we were to have moved to Symfony or another PHP framework we would have been dealing with the same issues &#8211; but there are more moving parts in the migrated application and the complexity of deployment means more time is spent thinking about the server than we would want.</p>
<p>When the server was purchased, we asked for a 2-Proc RAID 5 box with 4 GB of memory. The client gets a lot of traffic and is further sensitive to the perceived overhead of multiple box management vs &#8216;one big box&#8217;. That&#8217;s fine with me, we setup one box and let it roll. However we didn&#8217;t exactly request a 4 CPU box &#8211; we actually started with a 2 CPU box with 2GB of memory and then decided to upgrade to bigger hardware after only a few weeks with the smaller box.  </p>
<p>No problem &#8211; Rackspace took the machine down, swapped the motherboard, added the memory and we were good.</p>
<p>Fast forward to the Rails upgrade 1.5 years later. The box performance has generally been fine but in the back of my mind something wasn&#8217;t quite right about the actual server. Should i have benchmarked and solved this nagging feeling? Probably, but i&#8217;m not as familiar with Redhat as Ubuntu/Debian and so part of my feeling that it wasn&#8217;t performing as fast as it should i blamed on something related to RHEL4. But it&#8217;s a 4 CPU box and it has lots of memory, Rails should be fine with Apache and Passenger.</p>
<p><strong>But it wasn&#8217;t. </strong></p>
<p>We had some long running requests &#8211; Ruby seemed to get backed up behind &#8211; something? No problem, let&#8217;s make sure we&#8217;re doing everything we can to enable page caching &#8211; ok page level caching pretty much solved any performance issues. But still &#8211; deployments using capistrano clear the cache and the process of rebuilding up to 5,000 pages in the filesystem wasn&#8217;t fast. Deployments at particular times are out. Performance is good but not great, but not enough of a problem to cause anyone to question the configuration of the server. But that &#8220;PHP Feeling&#8221; of being able to deploy a change and have it instantly available just wasn&#8217;t there. This wouldn&#8217;t be a problem if the team wasn&#8217;t used to this flexibility of making changes at any moment, and I wasn&#8217;t happy with having to make an excuse for moving to Rails and ending up with a less flexible operation.</p>
<p>Our concerns, and experiences with other deployments, lead us to think that Apache/Passenger was the source of some of the slowness, so we decided to move to unicorn and nginx. The converstion from Apache to Nginx freed up a lot of memory, and unicorn&#8217;s graceful restart capability smoothed out performance during deployments. In part 2 we&#8217;ll cover in detail this conversion. It was a total success &#8211; overall throughput went up by a factor of 3, and deployments are now much smoother.</p>
<p><strong>However, were things as fast as they could be?</strong></p>
<p>In investigating an unrelated issue, we followed up with Rackspace on a Kernel patch that couldn&#8217;t be applied to our server. One of the technicians immediately realized why &#8211; we were not running the SMP kernel. For almost two years our 4 CPU Racehorse has been hopping on one leg around the track. Let&#8217;s look at the numbers: 9 am this morning, we switched to the proper kernel:<br />
<img src="http://www.rubyrescue.com/blog/wp-content/uploads/2009/10/Picture-15.png" alt="1 CPU vs 4 CPUs" title="1 CPU vs 4 CPUs" width="758" height="280" class="alignnone size-full wp-image-74" /></p>
<p>Every request is now almost twice as fast. Apache Bench says our throughput is 3.5 times greater. That stings a little. It feels a bit like i just <a href="http://www.amazon.com/Sea-Gray-Around-World-Confederate/dp/0809085046">piloted the Shenandoah 22,000 miles around the globe</a>, winning every battle, only to find out that the team <a href="http://en.wikipedia.org/wiki/American_Civil_War">lost the war</a> a few months before&#8230;</p>
<p>What should we have done differently? None of us are truly full-time &#8216;operations guys&#8217; &#8211; but we&#8217;re all really good developers and &#8216;good enough&#8217; at operations. We have no problem with configuring linux init files, syslogs, virtual ethernet interfaces, iptables, benchmarking tools, netcat, you name it &#8211; we&#8217;re pretty confident with the toolset. So why did we never cat /proc/cpuinfo ? And why did it take Rackspace 22 months to figure out that we were running a misconfigured server? Why did I have a spidey-sense (or is that spidy (spidie?) -sense?) that something was wrong with this server? And why didn&#8217;t I track it down as thoroughly as I could have? Why did I focus on the software vs hardware? But shouldn&#8217;t I be able to trust that Rackspace has that covered? What is the proper remedy for this failure from Rackspace? (They refunded the difference in price between the requested and &#8216;actual&#8217; hardware without hesitation.) Would we have made the same software changes if we were getting &#8216;good enough&#8217; performance from an actual 4 CPU system? Would we just be happily running on Apache/Passenger? </p>
<p>Answers to some of those questions in part two&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rubyrescue.com/blog/2009/10/27/cat-proccpuinfo-or-dont-trust-your-cores-to-rackspace-part-i/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
