<?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>AmmarkoV  `s  Personal Website &#187; Chromium</title>
	<atom:link href="http://ammar.gr/?feed=rss2&#038;tag=chromium" rel="self" type="application/rss+xml" />
	<link>http://ammar.gr</link>
	<description>I would love to change the world , but they won`t give me the source code</description>
	<lastBuildDate>Thu, 25 Oct 2012 11:53:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>Serving a WordPress site with Raspberry Pi ( and AmmarServer )</title>
		<link>http://ammar.gr/?p=531</link>
		<comments>http://ammar.gr/?p=531#comments</comments>
		<pubDate>Sat, 20 Oct 2012 12:41:40 +0000</pubDate>
		<dc:creator>Ammar Qammaz</dc:creator>
				<category><![CDATA[Post]]></category>
		<category><![CDATA[AmmarServer]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Benchmark]]></category>
		<category><![CDATA[Chromium]]></category>
		<category><![CDATA[planet]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://ammar.gr/?p=531</guid>
		<description><![CDATA[As I&#8217;ve mentioned before , one of the original goals of AmmarServer was getting rid of my current web server and replacing it with a Raspberry Pi. As one can easily notice this site is based on wordpress ( one thing that is a little harder to notice is that it is hosted in a [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;ve mentioned before , one of the original goals of AmmarServer was getting rid of my current web server and replacing it with a Raspberry Pi. As one can easily notice this site is based on wordpress ( one thing that is a little harder to notice is that it is hosted in a PC in my kitchen <img src='http://ammar.gr/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ) .  WordPress is a heavy burden even on my current Intel Based machine let alone on the slower Raspberry Pi.</p>
<p>There are tools that cache the wordpress web pages or imporve PHP performance but basically all of them try to work around quering the database and PHP interpreter  and serving static files instead.. </p>
<p>To add to the CPU limitations of the Pi , using an SD card also means delays when writing/and reading to disk ( <a href="http://en.wikipedia.org/wiki/Flash_memory#Memory_wear">not to mention the finite read/write cycles</a> ) when performing automatic caching operations , so instead of this I decided to add a script ( basically an alias for a wget call with the needed parameters ) that clones the whole site without hassle..   </p>
<p>If you want to try it and after cloning AmmarServer ( with &#8220;git clone git://github.com/AmmarkoV/AmmarServer &#8221; ) you can use the bash script provided in the repository and called &#8220;MirrorAmmarServer.sh&#8221;<br />
Lets say that your WordPress blog is hosted on http://ammar.gr .<br />
STEP 1 ) Being on the parent directory of AmmarServer  issue &#8220;./MirrorAmmarServer.sh http://ammar.gr&#8221;<br />
wget will gradually start to mirror the site into static files and create a subdirectory called ammar.gr/ where the files will be stored<br />
STEP 2 ) Edit the file src/main.c and change  char webserver_root[MAX_FILE_PATH]=&#8221;public_html/&#8221;; to char webserver_root[MAX_FILE_PATH]=&#8221;ammar.gr/&#8221;;<br />
If you want you can change the DEFAULT_BINDING_PORT to another port ( you may want to set it to port 80 because the default is 8080 )<br />
STEP 3 ) issue &#8220;./make &#038;&#038; ./run_ammarserver&#8221; and voila your site will be availiable at http://127.0.0.1:8080 ( or any other port you choose )</p>
<p>Here is a comparison of pinging the Raspberry Pi and pinging my Intel Based Server PC on a LAN<br />
<a href="http://ammar.gr/wp-content/uploads/2012/10/raspberry_pi_vs_intel_ping_times.png"><img src="http://ammar.gr/wp-content/uploads/2012/10/raspberry_pi_vs_intel_ping_times-300x98.png" alt="" title="raspberry_pi_vs_intel_ping_times" width="300" height="98" class="alignnone size-medium wp-image-567" /></a><br />
The ping times of the intel system have an average of 0.158 ms while the raspberry pi has an average time of 0.543 ms , almost 3-4 times worse.. </p>
<p>Here are some benchmarks conducted with chromium that give an overview of the performance difference ( all of the tests are done in a LAN so bandwidth is not a limiting factor ) : </p>
<p><a href="http://ammar.gr/wp-content/uploads/2012/10/FirstHit_apache_regular_wordpressVSammarserver_cached.png"><img src="http://ammar.gr/wp-content/uploads/2012/10/FirstHit_apache_regular_wordpressVSammarserver_cached-300x84.png" alt="" title="FirstHit_apache_regular_wordpressVSammarserver_cached" width="300" height="84" class="alignnone size-medium wp-image-540" /></a><br />
<em><strong>Left</strong> : First Uncached Hit , Apache Serving regular WordPress on my regular PC ( 1.33MB transferred , DOMContent loaded @ 494 ms , onload @ 1.35s )<br />
    <strong>Right</strong> : First Uncached Hit , AmmarServer serving cached static files on Raspberry Pi ( 1.39MB transferred , DOMContent loaded @ 159 ms , onload @ 968ms )  </em></p>
<p><a href="http://ammar.gr/wp-content/uploads/2012/10/HomeClicked2ndHit_apache_regular_wordpressVSammarserver_cached.png"><img src="http://ammar.gr/wp-content/uploads/2012/10/HomeClicked2ndHit_apache_regular_wordpressVSammarserver_cached-300x84.png" alt="" title="HomeClicked2ndHit_apache_regular_wordpressVSammarserver_cached" width="300" height="84" class="alignnone size-medium wp-image-542" /></a><br />
<em><strong>Left</strong> : Second Hit after clicking Home , Apache Serving regular WordPress on my regular PC ( 22.67KB transferred , DOMContent loaded @ 566 ms , onload @ 2.04s )<br />
    <strong>Right</strong> : Second Hit after clicking Home , AmmarServer serving cached static files on Raspberry Pi ( 61.54KB transferred , DOMContent loaded @ 140 ms , onload @ 515ms )  </em></p>
<p><a href="http://ammar.gr/wp-content/uploads/2012/10/2012-10-19-164015_3840x1080_scrot.png"><img src="http://ammar.gr/wp-content/uploads/2012/10/2012-10-19-164015_3840x1080_scrot-300x84.png" alt="Apache Serving cached static files on left compared to AmmarServer serving cached static files on right" title="Apache Serving cached static files on left compared to AmmarServer serving cached static files on right" width="300" height="84" class="alignnone size-medium wp-image-534" /></a><br />
<em><strong>Left</strong> : Apache Serving cached static files on my Regular PC<br />
    <strong>Right</strong> : AmmarServer serving cached static files on Raspberry Pi</em></p>
<p>Some things to notice is that in the static files version of the site , the image links on the menu bar that come directly from github , and the youtube embeds are the most laggy parts of the page and this distorts loading times. The onload event would drop by almost 400ms if they were part of the site.. </p>
<p>Performance also gets better by increasing the priority of the webserver  ( IRL decreasing it to -15 <img src='http://ammar.gr/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ) , removing cross-site content and making some other small tweaks. I have managed to drop times to around 50-60ms and I hope to further improve those numbers..</p>
<p>Network latency of course is the biggest bottleneck when dropping times so low and in any case even if i managed to serve the whole site from 60ms ( transaction latency ) + 150ms ( network latency )  in say 20ms  ( transaction latency )  + 150 ms ( network latency ) the perceived difference from the average client will be very small..</p>
<p>Thats it for now.. <img src='http://ammar.gr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://ammar.gr/?feed=rss2&#038;p=531</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
