<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Magpiebrain</title>
	
	<link>http://www.magpiebrain.com</link>
	<description />
	<lastBuildDate>Sun, 13 May 2012 17:07:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Magpiebrain" /><feedburner:info uri="magpiebrain" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site.</feedburner:browserFriendly><item>
		<title>The Empty Frame</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/k5Kc7zLDkPU/</link>
		<comments>http://www.magpiebrain.com/2012/05/13/the-empty-frame/#comments</comments>
		<pubDate>Sun, 13 May 2012 17:07:21 +0000</pubDate>
		<dc:creator>Sam Newman</dc:creator>
				<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/?p=1137</guid>
		<description><![CDATA[I was out shooting today, putting the x-pro through its paces. No real purpose &#8211; meandering around the Portobello Road, shooting stall keepers and tourists alike. I turn for home, walking alongside the westway, when a cyclist zips past. I see him, heading towards me, bring the camera up, track him and *click*. Enough time [...]]]></description>
			<content:encoded><![CDATA[<p>I was out shooting today, putting the x-pro through its paces. No real purpose &#8211; meandering around the Portobello Road, shooting stall keepers and tourists alike. I turn for home, walking alongside the westway, when a cyclist zips past. I see him, heading towards me, bring the camera up, track him and *click*. Enough time for one shot, and it&#8217;s perfect. He is captured on the top right, pin sharp, looking straight into the lens. The background is beautifully blurred. Perfect shot.</p>
<p>I walk on, and get a tap on my shoulder. I turn around to see the cyclist.</p>
<p>&#8220;Can you delete that, please?&#8221;.</p>
<p>And I do.</p>
<p>Walking back, I think idly &#8220;I could probably recover that&#8230;&#8221;. Legally, I&#8217;ve done nothing wrong. And it is a great shot &#8211; one of the best I think I&#8217;ve taken. But I sigh, and know I won&#8217;t. At least this is one shot I can&#8217;t claim to have lost due to the Fuji x-pro&#8217;s AF.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=k5Kc7zLDkPU:nh6R35Nrr24:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=k5Kc7zLDkPU:nh6R35Nrr24:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=k5Kc7zLDkPU:nh6R35Nrr24:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=k5Kc7zLDkPU:nh6R35Nrr24:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=k5Kc7zLDkPU:nh6R35Nrr24:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2012/05/13/the-empty-frame/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2012/05/13/the-empty-frame/</feedburner:origLink></item>
		<item>
		<title>lein-gentags: Generate TAGS file for your Clojure code</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/UzWQ_dyvMHU/</link>
		<comments>http://www.magpiebrain.com/2012/02/26/lein-gentags-generate-tags-file-for-your-clojure-code/#comments</comments>
		<pubDate>Sun, 26 Feb 2012 20:45:16 +0000</pubDate>
		<dc:creator>Sam Newman</dc:creator>
				<category><![CDATA[clojure]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[leiningen]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/?p=1134</guid>
		<description><![CDATA[Some yak shaving while playing around with Riemann resulted in me creating my first leiningen plugin, lein-gentags. It uses etags based on instructions from Nurullah Akkaya&#8217;s original blogpost &#8211; perfect for improving navigation of Clojure code in Emacs. Feedback appreciated!]]></description>
			<content:encoded><![CDATA[<p>Some yak shaving while playing around with Riemann resulted in me creating my first leiningen plugin, <a href="https://github.com/snewman/lein-gentags">lein-gentags</a>. It uses etags based on instructions from Nurullah Akkaya&#8217;s <a href="http://nakkaya.com/2009/12/13/getting-etags-to-index-clojure-files/">original blogpost</a> &#8211; perfect for improving navigation of Clojure code in Emacs. Feedback appreciated!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=UzWQ_dyvMHU:ZO7L6z6gA8M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=UzWQ_dyvMHU:ZO7L6z6gA8M:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=UzWQ_dyvMHU:ZO7L6z6gA8M:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=UzWQ_dyvMHU:ZO7L6z6gA8M:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=UzWQ_dyvMHU:ZO7L6z6gA8M:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2012/02/26/lein-gentags-generate-tags-file-for-your-clojure-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2012/02/26/lein-gentags-generate-tags-file-for-your-clojure-code/</feedburner:origLink></item>
		<item>
		<title>New Talk: Designing For Rapid Release</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/AN8QfZr_vE0/</link>
		<comments>http://www.magpiebrain.com/2012/01/14/new-talk-designing-for-rapid-release/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 18:23:48 +0000</pubDate>
		<dc:creator>Sam Newman</dc:creator>
				<category><![CDATA[Build And Deployment]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[presentations]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/?p=1129</guid>
		<description><![CDATA[I&#8217;ll be running my new talk &#8220;Designing For Rapid Release&#8221; at a couple of conferences in the first half of this year. First up is the delightfully named Crash &#038; Burn in Stockholm, on the 2nd of March. Then later in May I&#8217;ll be at Poznan in Poland for GeeCon 2012. This talk focuses on [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be running my new talk &#8220;Designing For Rapid Release&#8221; at a couple of conferences in the first half of this year. First up is the delightfully named <a href="http://swdc.se/crashandburn2012/">Crash &#038; Burn</a> in Stockholm, on the 2nd of March. Then later in May I&#8217;ll be at Poznan in Poland for <a href="http://2012.geecon.org/">GeeCon 2012</a>. </p>
<p>This talk focuses on the kinds of constraints we should consider when evolving their architecture of our systems in order to enable rapid, frequent release. So much of the conversation about Continuous Delivery focuses on the design of build pipelines, or the nuts and bolts of CI and infrastructure automation. But often the biggest constraint in being able to incrementally roll out new features are the problems in the design of the system itself. I&#8217;ll be pulling together a series of patterns that will help you identify what to look for in your own systems when moving towards Continuous Delivery.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=AN8QfZr_vE0:CVq-2iwib-Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=AN8QfZr_vE0:CVq-2iwib-Q:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=AN8QfZr_vE0:CVq-2iwib-Q:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=AN8QfZr_vE0:CVq-2iwib-Q:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=AN8QfZr_vE0:CVq-2iwib-Q:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2012/01/14/new-talk-designing-for-rapid-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2012/01/14/new-talk-designing-for-rapid-release/</feedburner:origLink></item>
		<item>
		<title>Using Fabric to apply Puppet scripts</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/vKakzvMfShA/</link>
		<comments>http://www.magpiebrain.com/2011/08/21/using-fabric-to-apply-puppet-scripts/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 15:20:54 +0000</pubDate>
		<dc:creator>Sam Newman</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[boto]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[fabric]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/?p=1120</guid>
		<description><![CDATA[On my current client project, in terms of managing configuration of the various environments, I have separated things into two problem spaces &#8211; provisioning hosts, and configuring hosts. Part of the reason for this separation is that although targeting AWS, we do need to allow us to support alternative services in the future, but I [...]]]></description>
			<content:encoded><![CDATA[<p>On my current client project, in terms of managing configuration of the various environments, I have separated things into two problem spaces &#8211; provisioning hosts, and configuring hosts. Part of the reason for this separation is that although targeting AWS, we do need to allow us to support alternative services in the future, but I also consider the type of tasks to be rather different and to require different types of tools.</p>
<p>For provisioning hosts I am using the Python AWS API <a href="http://boto.cloudhackers.com/">Boto</a>. For configuring the hosts once provisioned, I am using Puppet. I remain unconvinced as to the relative merits of PuppetMaster or Chef Server (see <a href="http://www.magpiebrain.com/2010/10/20/chef-versioned-recipes/">my previous post</a> on the subject) and so have decided to stick with using PuppetSolo so I can manage versioning how I would like. This leaves me with a challenge &#8211; how do I apply the puppet configuration for the hosts once provisioned with Boto? I also wanted to provide a relatively uniform command-line interface to the development team for other tasks like running builds etc. Some people use cron-based polling for this, but I wanted a more direct form of control. I also wanted to avoid the need to run any additional infrastructure, so mcollective was never something I was particularly interested in.</p>
<p>After a brief review of my &#8220;Things I should look at later&#8221; list it looked like time to give <a href="http://docs.fabfile.org/">Fabric</a> a play.</p>
<p>Fabric is a Python-based tool/library which excels at creating command-line tools for machine management. It&#8217;s bread and butter is script-based automation of machines via SSH &#8211; many people in fact use hand-rolled scripts on top of Fabric as an alternative to systems like Chef and Puppet. The documentation is very good, and I can heartily recommend the <a href="http://docs.fabfile.org/en/1.2.0/tutorial.html">Fabric tutorial</a>.</p>
<p>The workflow I wanted was simple. I wanted to be able to checkout a specific version of code locally, run one command to bring up a host and also apply a given configuration set. My potentially naive solution to this problem is to simply tar up my puppet scripts, upload them, and then run puppet. Here is the basic script:</p>
<pre class="brush: python; title: ; notranslate">
@task
def provision-box():
  public_dns = provision_using_boto()

  local(&quot;tar cfz /tmp/end-bundle.tgz path/to/puppet_scripts/*&quot;)
  with settings(host_string=public_dns, user=&quot;ec2-user&quot;, key_filename=&quot;path/to/private_key.pem&quot;):
    run(&quot;sudo yum install -y puppet&quot;)
    put(&quot;/tmp/end-bundle.tgz&quot;, &quot;.&quot;)
    run(&quot;tar xf end-bundle.tgz &amp;&amp; sudo puppet --modulepath=/home/ec2-user/path/to/puppet_scripts/modules path/to/puppet_scripts/manifests/myscript.pp&quot;)
</pre>
<p>The <code>provision_using_boto()</code> command is an exercise left to the reader, but <a href="http://boto.cloudhackers.com/ec2_tut.html">the documentation</a> should point you in the right direction. If you stuck the above command in your <code>fabfile.py</code>, all you need to do is run <code>fab provision-box</code> to do the work. The first <code>yum install</code> command is there to handle bootstraping of puppet (as it is not on the AMIs we are using) &#8211; this will be a noop if the target host already has it installed.</p>
<p>This example is much more simplified than the actual scripts as we have also implemented some logic to re-use ec2 instances to save time &#038; money, and also a simplistic role system to manage different classes of machines. I may write up those ideas in a future post.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=vKakzvMfShA:hHg2Qgdf_Os:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=vKakzvMfShA:hHg2Qgdf_Os:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=vKakzvMfShA:hHg2Qgdf_Os:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=vKakzvMfShA:hHg2Qgdf_Os:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=vKakzvMfShA:hHg2Qgdf_Os:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2011/08/21/using-fabric-to-apply-puppet-scripts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2011/08/21/using-fabric-to-apply-puppet-scripts/</feedburner:origLink></item>
		<item>
		<title>Upcoming speaking event @ JAX London</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/zSNEOAPnonU/</link>
		<comments>http://www.magpiebrain.com/2011/07/16/upcoming-speaking-event-jax-london/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 18:27:37 +0000</pubDate>
		<dc:creator>Sam Newman</dc:creator>
				<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[presentations]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[jax]]></category>
		<category><![CDATA[speaking]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/?p=1114</guid>
		<description><![CDATA[I&#8217;ll be speaking on the cloud track at JAX London 2011. The talk &#8220;Private Cloud, A Convenient Fiction&#8221; attempts to puncture some of the FUD on the subject. The nuances between various hosting solutions are many and varied, and don&#8217;t suit being put into neat boxes like &#8216;public&#8217; and &#8216;private&#8217;. When I talk to clients [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be speaking on the cloud track at JAX London 2011. The talk &#8220;<a href="http://jaxlondon.com/2011/sessions/?tid=2174">Private Cloud, A Convenient Fiction</a>&#8221; attempts to puncture some of the FUD on the subject. The nuances between various hosting solutions are many and varied, and don&#8217;t suit being put into neat boxes like &#8216;public&#8217; and &#8216;private&#8217;. When I talk to clients about what is right to them, the types of things we discuss place different providers on a number of axis, which I hope to get across in this talk.</p>
<p>As always, you can track the conference (or note that you plan to attend) at Simon &#038; Nat&#8217;s startup <a href="http://lanyrd.com/2011/jax-london-autumn/">Lanyrd</a>, which is several shades of awesome. </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=zSNEOAPnonU:CKPsXQX6nAY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=zSNEOAPnonU:CKPsXQX6nAY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=zSNEOAPnonU:CKPsXQX6nAY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=zSNEOAPnonU:CKPsXQX6nAY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=zSNEOAPnonU:CKPsXQX6nAY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2011/07/16/upcoming-speaking-event-jax-london/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2011/07/16/upcoming-speaking-event-jax-london/</feedburner:origLink></item>
		<item>
		<title>Apache and the case of the missing memory</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/HUUUofPctCc/</link>
		<comments>http://www.magpiebrain.com/2011/07/13/apache-and-the-case-of-the-missing-memory/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 11:26:40 +0000</pubDate>
		<dc:creator>Sam Newman</dc:creator>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/?p=1106</guid>
		<description><![CDATA[It seems I spoke too soon. Just one day after thinking I had tracked down the source of the trouble, and yesterday evening brought another outage. The graph in CloudWatch was all too familiar, showing the huge uptick in CPU use. The box was again unresponsive and had to be restarted. Checking cpu_log for a [...]]]></description>
			<content:encoded><![CDATA[<p>It seems I <a href="http://www.magpiebrain.com/2011/07/12/tracking-down-rogue-processes/">spoke too soon</a>. Just one day after thinking I had tracked down the source of the trouble, and yesterday evening brought another outage. The graph in CloudWatch was all too familiar, showing the huge uptick in CPU use. The box was again unresponsive and had to be restarted. Checking <code>cpu_log</code> for a likely culprit, the entries looked odd:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
2011-07-13 00:12:22 www-data 26096 21.4  0.9 160732  5972 ?        D    Jul12   5:30 /usr/sbin/apache2 -k start
2011-07-13 00:12:25 www-data 26096 21.4  0.9 160736  6040 ?        R    Jul12   5:30 /usr/sbin/apache2 -k start
2011-07-13 00:12:22 www-data 26096 21.3  0.9 160732  5972 ?        D    Jul12   5:30 /usr/sbin/apache2 -k start
2011-07-13 00:12:22 root     26179 24.0  0.0   4220   584 ?        S    00:12   0:00 /bin/sh /home/ubuntu/tools/cpu_log
</pre>
<p>No entries from Postfix &#8211; good &#8211; but now other processes are having trouble. This was starting to point away from one rogue process gobbling CPU, to high CPU use being a symptom of something else. What can cause very high CPU use? Among other things, swapping memory. A process chewing up all available memory could easily cause these kinds of symptoms. A quick scan through <code>syslog</code> showed me something I should have spotted earlier. If it wasn&#8217;t the smoking gun, then at least something pretty close:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
Jul 13 00:11:28 domU-12-31-39-01-F0-E5 kernel: [38837.985499] apache2 invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0
</pre>
<p>This doesn&#8217;t mean that Apache is to blame, just that it was a process which oom-killer tried to take out in order to free up memory. And just prior to the outage itself in the apache logs:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
[Tue Jul 12 23:48:24 2011] [error] (12)Cannot allocate memory: fork: Unable to fork new process
</pre>
<p>At this point my mind was already turning to the fact that I hadn&#8217;t done *any* tuning of Apache processes or PHP. After googling around for a bit, a few things looked wrong in my config. Here was the untuned default that Ubuntu gave me:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
&lt;IfModule mpm_prefork_module&gt;
    StartServers            5
    MinSpareServers         5
    MaxSpareServers        10
    MaxClients            150
    MaxRequestsPerChild     0
&lt;/IfModule&gt;
</pre>
<p>In general <code>MaxClients</code> refers to the maximum number of simultaneous requests that will be served. On prefork Apache, like mine, <code>MaxClients</code> also refers to the max number of child processes that get spawned. A simple <code>ps</code> showed that even after a restart, each apache process was consuming up to 35MB of memory. The host in question has 1GB in RAM &#8211; it was clear that even with nothing else running on the box, with that sort of memory footprint I would exhaust memory way before the <code>MaxClients</code> threshold was reached. Even more worrying, the <code>MaxRequestsPerChild</code> was set to zero, meaning that the child processes would never be restarted. If a memory leak was occurring inside the child Apache process, it could carry on eating memory until the box comes crashing to it&#8217;s knees. After some quick maths I decided to reduce my <code>MaxClients</code> down to a more manageable 25, but also set <code>MaxRequestsPerChild</code> to 1000. My hope is that this may buy me some more time to try and track down where the memory use is occurring.</p>
<p>This has spurned me on to finally invest some time looking at nginx. This weekend may see me putting in nginx side by side with a view to moving away from Apache &#8211; from all reports this may allow me to run my sites with a much lower footprint. But if the last couple of days has taught me anything, it&#8217;s that I should be so sure to rush to the conclusion that I&#8217;ve finally tracked this problem down. If I&#8217;m still having trouble at the weekend, I may well just clone the box and try and reproduce the problem with some performance tests.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=HUUUofPctCc:OhmwsJ3-noI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=HUUUofPctCc:OhmwsJ3-noI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=HUUUofPctCc:OhmwsJ3-noI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=HUUUofPctCc:OhmwsJ3-noI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=HUUUofPctCc:OhmwsJ3-noI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2011/07/13/apache-and-the-case-of-the-missing-memory/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2011/07/13/apache-and-the-case-of-the-missing-memory/</feedburner:origLink></item>
		<item>
		<title>Tracking down rogue processes</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/AVRS3BUMNPA/</link>
		<comments>http://www.magpiebrain.com/2011/07/12/tracking-down-rogue-processes/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 20:00:20 +0000</pubDate>
		<dc:creator>Sam Newman</dc:creator>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/?p=1093</guid>
		<description><![CDATA[I&#8217;m in the process of migrating the many sites I manage from Slicehost over to EC2 (which is where this blog is currently running). I hit a snag in the last day or two &#8211; my Montastic alerts told me that the sites I had already migrated were not responding. I tried &#8211; and failed [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the process of migrating the many sites I manage from Slicehost over to EC2 (which is where this blog is currently running). I hit a snag in the last day or two &#8211; my Montastic alerts told me that the sites I had already migrated were not responding. I tried &#8211; and failed &#8211; to SSH into the box. The CloudWatch graphs for the instance showed a 100% CPU use, explaining SSH being unresponsive. The problem is that I couldn&#8217;t tell what was causing the problem. My only option was to restart the instance, which at least brought it back to life.</p>
<p>What I needed was something that would tell me what was causing the problem. After reaching out to <a href="http://www.thoughtworks.com/">The Hive Mind</a>, <a href="http://offbytwo.com/">Cosmin</a> pointed me in the direction of some <code>awk</code> and <code>ps</code> foo. This little script gets a process listing, and writes out all those rows where the CPU is above 20%, prepended with the current timestamp: </p>
<pre class="brush: plain; light: true; title: ; notranslate">
ps aux  | gawk '{ if ( $3 &gt; 20 ) { print strftime(&quot;%Y-%m-%d %H:%M:%S&quot;)&quot; &quot;$0 } }
</pre>
<p>My box rarely goes about 5% CPU use, and I was worried about the CPU ramping up so quickly that I didn&#8217;t get a sample, so this threshold seemed sensible. The magic is the <code>if ( $3 > 20)</code> &#8211; this only emits the line if the third column of input from <code>ps aux</code> (which is the CPU) goes above 20.</p>
<p>I put the one-liner in a script, then stuck the following entry into <code>cron</code> to ensure that every minute, the script gets run. If everything is ok, no output. Otherwise, I&#8217;ll get the full process listing. This wouldn&#8217;t top the box getting wedged again, but would at least tell me what caused it.</p>
<pre class="brush: plain; light: true; title: ; notranslate">
* * * * * root /home/ubuntu/tools/cpu_log &gt;&gt; /var/log/cpu_log
</pre>
<p>Lo and behold, several hours later and the box got wedged once again. After a restart, the <code>cpu_log</code> showed this:</p>
<pre class="brush: plain; light: true; title: ; wrap-lines: false; notranslate">
2011-07-11 17:55:42 postfix   6398 29.6  0.3  39428  2184 ?        S    17:55   0:01 pickup -l -t fifo -u -c
2011-07-11 17:55:42 postfix   6398 29.6  0.3  39428  2180 ?        S    17:55   0:01 pickup -l -t fifo -u -c
2011-07-11 17:55:42 postfix   6398 29.6  0.2  39428  1556 ?        S    17:55   0:01 pickup -l -t fifo -u -c
2011-07-11 17:55:42 postfix   6398 24.6  0.2  39428  1368 ?        S    17:55   0:01 pickup -l -t fifo -u -c
2011-07-11 18:16:43 root      6440 50.0  0.0  30860   344 ?        R    18:16   0:01 pickup -l -t fifo -u -c
</pre>
<p>Matching what the CloudWatch graphs showed me, the CPU ramped up quote quickly, before I loose all output (the 4th column here is CPU). But this time, we have a culprit &#8211; Postfix&#8217;s <code>pickup</code> process. I had configured Postfix just a day or two back, so clearly something was amiss. Nonetheless, I can at least now disable Postfix to spend some time diagnosing the problem.</p>
<h3>Limiting CPU</h3>
<p>Something else that was turned up in my cries for help was <a href="http://cpulimit.sourceforge.net/">cpulimit</a>. This utility would allow me to cap how much CPU a given process used. If and when I re-enable postfix, I&#8217;ll almost certainly use this to avoid future outages while I iron out any kinks.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=AVRS3BUMNPA:xpnfgUWgA4A:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=AVRS3BUMNPA:xpnfgUWgA4A:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=AVRS3BUMNPA:xpnfgUWgA4A:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=AVRS3BUMNPA:xpnfgUWgA4A:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=AVRS3BUMNPA:xpnfgUWgA4A:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2011/07/12/tracking-down-rogue-processes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2011/07/12/tracking-down-rogue-processes/</feedburner:origLink></item>
		<item>
		<title>Briefed</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/CXcZqCTPsHg/</link>
		<comments>http://www.magpiebrain.com/2011/07/09/briefed/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 16:43:00 +0000</pubDate>
		<dc:creator>Sam Newman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/2011/07/09/briefed/</guid>
		<description><![CDATA[My new wordpress theme I think]]></description>
			<content:encoded><![CDATA[<p>My new wordpress theme I think</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=CXcZqCTPsHg:PQ3n4qCjZ6Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=CXcZqCTPsHg:PQ3n4qCjZ6Y:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=CXcZqCTPsHg:PQ3n4qCjZ6Y:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=CXcZqCTPsHg:PQ3n4qCjZ6Y:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=CXcZqCTPsHg:PQ3n4qCjZ6Y:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2011/07/09/briefed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2011/07/09/briefed/</feedburner:origLink></item>
		<item>
		<title>links for 2011-05-08</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/yDt1A8T6DZM/</link>
		<comments>http://www.magpiebrain.com/2011/05/08/links-for-2011-05-08/#comments</comments>
		<pubDate>Sun, 08 May 2011 21:01:07 +0000</pubDate>
		<dc:creator>delicious</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/2011/05/08/links-for-2011-05-08/</guid>
		<description><![CDATA[AWS Benchmarks and Best Practices &#8211; Greplin:tech Interesting benchmarking of AWS EBS volumes and resulting recommendations. Worth reading if you&#039;re using EBS volumes for any purpose. (tags: ebs aws cloud sysadmin filesystem)]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://tech.blog.greplin.com/aws-best-practices-and-benchmarks">AWS Benchmarks and Best Practices &#8211; Greplin:tech</a></div>
<div class="delicious-extended">Interesting benchmarking of AWS EBS volumes and resulting recommendations. Worth reading if you&#039;re using EBS volumes for any purpose.</div>
<div class="delicious-tags">(tags: <a href="http://www.delicious.com/padark/ebs">ebs</a> <a href="http://www.delicious.com/padark/aws">aws</a> <a href="http://www.delicious.com/padark/cloud">cloud</a> <a href="http://www.delicious.com/padark/sysadmin">sysadmin</a> <a href="http://www.delicious.com/padark/filesystem">filesystem</a>)</div>
</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=yDt1A8T6DZM:Qg1vuETLrhQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=yDt1A8T6DZM:Qg1vuETLrhQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=yDt1A8T6DZM:Qg1vuETLrhQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=yDt1A8T6DZM:Qg1vuETLrhQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=yDt1A8T6DZM:Qg1vuETLrhQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2011/05/08/links-for-2011-05-08/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2011/05/08/links-for-2011-05-08/</feedburner:origLink></item>
		<item>
		<title>links for 2011-05-03</title>
		<link>http://feedproxy.google.com/~r/Magpiebrain/~3/uP9dVoX4zfk/</link>
		<comments>http://www.magpiebrain.com/2011/05/03/links-for-2011-05-03/#comments</comments>
		<pubDate>Tue, 03 May 2011 21:01:37 +0000</pubDate>
		<dc:creator>delicious</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.magpiebrain.com/2011/05/03/links-for-2011-05-03/</guid>
		<description><![CDATA[jedi4ever/veewee &#8211; GitHub (tags: devops vagrant)]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="https://github.com/jedi4ever/veewee">jedi4ever/veewee &#8211; GitHub</a></div>
<div class="delicious-tags">(tags: <a href="http://www.delicious.com/padark/devops">devops</a> <a href="http://www.delicious.com/padark/vagrant">vagrant</a>)</div>
</li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=uP9dVoX4zfk:MWKE094C9iU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=uP9dVoX4zfk:MWKE094C9iU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=uP9dVoX4zfk:MWKE094C9iU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?i=uP9dVoX4zfk:MWKE094C9iU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Magpiebrain?a=uP9dVoX4zfk:MWKE094C9iU:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/Magpiebrain?d=dnMXMwOfBR0" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.magpiebrain.com/2011/05/03/links-for-2011-05-03/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.magpiebrain.com/2011/05/03/links-for-2011-05-03/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.377 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-05-27 21:12:17 -->

