<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>egolog</title>
    <link rel="alternate" type="text/html" href="http://egolog.com/blog/" />
    <link rel="self" type="application/atom+xml" href="http://egolog.com/blog/atom.xml" />
    <id>tag:egolog.com,2007-12-10:/blog//2</id>
    <updated>2008-02-06T11:17:26Z</updated>
    
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Publishing Platform 4.01</generator>

<entry>
    <title>Mental Wanking and Premature Optimization</title>
    <link rel="alternate" type="text/html" href="http://egolog.com/blog/2007/12/25/mental-wanking-and-premature-optimization" />
    <id>tag:egolog.com,2007:/blog//2.361</id>

    <published>2007-12-25T22:53:38Z</published>
    <updated>2008-02-06T11:17:26Z</updated>

    <summary>Optimization appeals to us geeks. I am sure there is some psychological reason for this, If you happen to know what the reason is then drop me a line. I promise not about to witter on about The Fallacy of...</summary>
    <author>
        <name>Harry</name>
        <uri>http://www.hjackson.org/</uri>
    </author>
    
        <category term="Optimization" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="mentalwankingprematureoptimization" label="Mental Wanking Premature Optimization" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://egolog.com/blog/">
        <![CDATA[<span class="mt-enclosure mt-enclosure-image"><a href="http://egolog.com/blog/bugatti-veyron.jpg"><img alt="bugatti-veyron.jpg" src="http://egolog.com/blog/bugatti-veyron-thumb-300x181.jpg" class="mt-image-right" style="margin: 0pt 0pt 20px 20px; float: right;" height="181" width="300" /></a></span>Optimization appeals to us geeks. I am sure there is some psychological reason for this, If you happen to know what the reason is then drop me a line. I promise not about to witter on about <a href="http://www.acm.org/ubiquity/views/v7i24_fallacy.html">The Fallacy of Premature Optimization </a>either. Optimization is important but far too many of us get caught up in pointless arguments about performance.  The following article deals specifically with the faster webserver, in particular serving static pages. <br /><br />There's a ton of articles on Apache vs Apache2 vs lightttpd vs thttpd vs mongrel vs nginx vs litespeed vs whatever-httpd. The vast majority of these articles cater for people not adverse to a bit of mental wanking. These people have a <b>perceived</b> problem ie performance. They want to get an extra few percent from their machine. Off they go on their merry way Googling for a performance comparison chart that will show them some stats. These people are the unadulterated speed freaks of the computing world. A lot of them understand their... affliction, but quite a few don't.<br />
<br />
<p>In some organizations performance is critical ie Yahoo, Google, Wikipedia, livejournal, BBC,  Dozens of Universities, Any bank, etc.... I am missing hundreds here. For some it's competitive advantage ie Google. For these organizations performance is talked about all the time. It's brought up in meetings, at the bar, over lunch, out jogging and in their dreams. It has a direct affect on the bottom line.<br />
</p>My point is this, most people online discussing the relative merits of Apache vs Apache2 vs lighttpd are not in this select group, most are running small websites.

<br />
<br />
<p>
Here are some idle thoughts that may help the more pragmatic developers out there.<br /><br />A fairly common question asked is. "What hardware do we need to sustain "N" requests per second"? Assume a static page is 25KB.  If we also assume that we have an eCPM of $1.00 (and this is a small amount) we can put "N" in perspective......<br /></p><br /><ol><li>1&nbsp;&nbsp; rps&nbsp; == 2,592,000 &nbsp; &nbsp;&nbsp; rpm == $2592 per month<br /></li><li>10 rps&nbsp; == 25,920,000&nbsp;&nbsp;&nbsp;&nbsp; rpm == $25,920 pm<br /></li>
<li>50&nbsp; &nbsp; &nbsp;&nbsp; == 129,600,000&nbsp;&nbsp; rpm == $129,600 pm<br /></li>
<li>100 &nbsp; &nbsp; == 259,200,000&nbsp;&nbsp; rpm == $259,200 pm<br /></li>
<li>500 &nbsp; &nbsp; == 1,296,000,000&nbsp; rpm == $1.296 million per month<br /></li>
</ol>
<br />
<p>
500 pages per second is nearly 1.3 Billion Pages per month. This is an awful lot of pages and $1.3 million dollars is certainly an awful lot of money. On hearing 500rps as a requirement a common reaction is to jump too Google and start looking for a suitable configuration. It would be far simpler and more enlightening to do a few calculations and a small test to see where we stand.</p> 

<p>
For instance:
<br />
<br />
500 * 25KB requests per second == (500*25*1024*8)b/ps == 104Mb/s
<br />
<br />
This is a serious requirement. A 100Mb dedicated line is not cheap and would be likely to set you back several thousand dollars per month but hey we are making $1.3 Million per month, who cares!
</p>Now, if I was to go out and spend $2000 dollars on a server just how many pages could it serve. Lets assume I own the following machine:
<br /><p>
<br />
</p><ul>
<li>Dell 2850</li>
<li>RAM: 2GB</li><li>
</li><li>model name: Intel(R) Xeon(TM) CPU 2.80GHz</li>
<li>cpu family: 15</li>
<li>6 10K SCSI disks (2 mirrored, 4 in raid 10)</li>
</ul>

Basically a decent spec 2005/6 Single Processor Dual Core machine with the OS disks on a raid 1 array and the web server serving pages from the raid 10 array.<br /><br />So, is it possible for this single machine to serve 500rps? Yes! It could, if we had enough bandwidth! The following results were taken from a base install Debian machine. I did not tune apache2 in any way whatsoever. This was done on a 100Mb Ethernet network.<br /><br />debian:~# ab -n 10000 -c 50 http://farty.com/<br />This is ApacheBench, Version 2.0.40-dev <br />Completed 1000 requests<br />.........<br />Finished 10000 requests<br /><br />Server Software: Apache/2.2.3<br />Server Hostname:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; farty.com<br />Server Port: 80<br /><br />Document Path:&nbsp;&nbsp; /<br />Document Length: 25000 bytes<br />Concurrency Level: 50<br />Time taken for tests: 21.877168 seconds<br />Complete requests: 10000<br />Failed requests: 0<br />Total transferred: 252929056 bytes
<br />HTML transferred: 250243696 bytes
<br />Requests per second: 457.10 [#/sec] (mean)<br />Time per request: 109.386 [ms] (mean)<br />Time per request: 2.188 [ms] (mean, across all concurrent requests)<br />Transfer rate: 11290.35 [Kbytes/sec] received<br /><br />
I know ab is not the best tool to be running benchmarks and that requesting a single file is different thatn random files etc but I am not trying to be precise.
<br />
<br />
So, a cheap machine can saturate a 100Mbit line. Yes, Easily. At no point during the tests did the server go over 0.5 load. I also ran a more long running test and the results were the same. It hardly broke a sweat and this is running an unmodified, untweaked pre-forking Apache2 server.<br /><br /><span class="mt-enclosure mt-enclosure-image"><a href="http://egolog.com/blog/im_AH64ApacheHelicopter.jpg"><img alt="im_AH64ApacheHelicopter.jpg" src="http://egolog.com/blog/im_AH64ApacheHelicopter-thumb-300x237.jpg" class="mt-image-right" style="margin: 0pt 0pt 20px 20px; float: right;" height="237" width="300" /></a></span>
<br />
<p>
So whats the conclusion, is benchmarking Apache2 vs lighttpd pointless? I would say that 99% of the time, yes. If you ever have the problem were you need to be serving the amount of pages where the difference between Apache2 and lighttpd makes a big difference then you are likely able to afford more hardware or staff but I wouldn't be choosing lighttpd over Apache2 unless I really have to.<br /><br /><br />Heres a quote from a <a href="http://kb.pert.switch.ch/cgi-bin/twiki/view/PERTKB/ApacheScaling">20000 concurrent connection apache setup</a><br /></p><p><br /></p>


<blockquote>
<p>... HEAnet's National Mirror Server for Ireland. Currently
mirroring over 50,000 projects .....<b> It regularly sustains over 20,000
concurrent connections on a single Apache instance</b> and has served as
many as 27,000 with about 3.5 Terabytes of content per day. The
front-end system is a Dell 2650, with 2 2.4 Ghz Xeon processors, 12Gb
of memory and the usual 2 system disks and 15k RPM SCSI disks, running
Debian GNU/Linux and Apache 2.x. <br /></p></blockquote>


So the next time you hear someone discussing how fast their httpd server is at serving static content ask yourself if they are just jerking off or do they know what they are talking about.
]]>
        
    </content>
</entry>

<entry>
    <title>I am Biased</title>
    <link rel="alternate" type="text/html" href="http://egolog.com/blog/2007/12/20/i-am-biased" />
    <id>tag:egolog.com,2007:/blog//2.360</id>

    <published>2007-12-20T21:31:27Z</published>
    <updated>2007-12-25T23:36:48Z</updated>

    <summary><![CDATA[Disclaimer: I am biased because..... I'm a pragmatist! I have taken Honey &amp; Mumford's learning styles test and had the following score..... Activist: 10 Reflector: 15 Theorist: 11 Pragmatist: 17 What does this mean? Basically I want results. Idle chit...]]></summary>
    <author>
        <name>Harry</name>
        <uri>http://www.hjackson.org/</uri>
    </author>
    
        <category term="General" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="pragmatist" label="Pragmatist" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://egolog.com/blog/">
        <![CDATA[<span class="mt-enclosure mt-enclosure-image"><a href="http://egolog.com/blog/scales.jpeg"><img alt="scales.jpeg" src="http://egolog.com/blog/assets_c/2007/12/scales-thumb-250x227.jpeg" class="mt-image-right" style="margin: 0pt 0pt 20px 20px; float: right;" height="227" width="250" /></a></span>Disclaimer: I am biased because.....

I'm a pragmatist! I have taken <a href="http://www.google.com/search?q=honey+mumford">Honey &amp; Mumford's</a> learning styles test and had the following score.....<br /><br />

<ul>
<li>Activist: 10</li>
<li>Reflector: 15</li>
<li>Theorist: 11</li>
<li>Pragmatist: 17</li>
</ul>

What does this mean? Basically I want results. Idle chit chat and people waxing lyrical bore me. Show me the numbers, the evidence, the proof. I might also add here that I am skeptical of other peoples numbers. I tend to prove things for myself.<div><br /></div><div><br /></div><div><br /></div>]]>
        
    </content>
</entry>

<entry>
    <title>Mental Masturbation</title>
    <link rel="alternate" type="text/html" href="http://egolog.com/blog/2007/12/20/mental-masturbation" />
    <id>tag:egolog.com,2007:/blog//2.362</id>

    <published>2007-12-20T20:29:04Z</published>
    <updated>2007-12-26T01:30:03Z</updated>

    <summary><![CDATA[My definition of Mental Wanking reads like a medical affliction.Main Entry:men·tal&nbsp;mas·tur·ba·tionmental stimulation, especially of one's own mind commonly resulting in time wasting. Can be achieved by missing the point or an acute lack of realism. More prevalent in certain fields,...]]></summary>
    <author>
        <name>Harry</name>
        <uri>http://www.hjackson.org/</uri>
    </author>
    
        <category term="Ranting" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="mentalwanking" label="Mental Wanking" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://egolog.com/blog/">
        <![CDATA[My definition of Mental Wanking reads like a medical affliction.<br /><span class="mt-enclosure mt-enclosure-image"><a href="http://egolog.com/blog/mental-wanking.jpg"><img alt="mental-wanking.jpg" src="http://egolog.com/blog/mental-wanking-thumb-300x187.jpg" class="mt-image-right" style="margin: 0pt 0pt 20px 20px; float: right;" height="187" width="300" /></a></span><br /><dl><dt class="hwrd">Main Entry:</dt><dd class="hwrd"><span class="variant">men·tal</span>&nbsp;<span class="variant">mas·tur·ba·tion</span></dd></dl><span class="sense_content"><strong></strong>mental
stimulation, especially of one's own mind commonly resulting
in time wasting. Can be achieved by missing the point or an
acute lack of realism. More prevalent in certain fields, critics ( in
particular literature ), software engineers, tv buffs etc. Can
occasionally be accompanied by
mental fantasies, arrogance, bad temper and or delusions.</span><br /><br />For those looking for individual definitions of the word I took the following from Websters.<br /><br /><div class="entry misc">
  <dl><dt class="hwrd">Main Entry:</dt><dd class="hwrd"><span class="variant">mas·tur·ba·tion</span></dd></dl><div class="defs"><span class="sense_content"><strong>:</strong>&nbsp;erotic
stimulation especially of one's own genital organs commonly resulting
in orgasm and achieved by manual or other bodily contact exclusive of
sexual intercourse, by instrumental manipulation, occasionally by
sexual fantasies, or by various combinations of these agencies<br /><br /><br />And the following entry for Mental:<br /></span><br />
  <dl><dt class="hwrd">Main Entry:</dt><dd class="hwrd"><span class="variant"><sup>1</sup>men·tal</span>&nbsp;</dd></dl>
  <span class="sense_break"><span class="sense_label start">1 a</span><span class="sense_content"><strong>:</strong>&nbsp;of or relating to the mind</span><span class="sense_content">; <em>specifically</em></span> <span class="sense_content"><strong>:</strong>&nbsp;of or relating to the total emotional and intellectual response of an individual to external reality <span class="vi">&lt;<em>mental</em> health&gt;</span></span> <span class="sense_label">b</span><span class="sense_content"><strong>:</strong>&nbsp;of or relating to intellectual as contrasted with emotional activity</span></span><br /><span class="sense_content"><br /></span>
  </div>
<span class="sense_content"></span></div>]]>
        
    </content>
</entry>

</feed>
