<?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; Web Server</title>
	<atom:link href="http://ammar.gr/?feed=rss2&#038;tag=web-server" 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>
		<item>
		<title>ETags 304 Not Modified and 200 OK headers..!</title>
		<link>http://ammar.gr/?p=520</link>
		<comments>http://ammar.gr/?p=520#comments</comments>
		<pubDate>Wed, 17 Oct 2012 16:01:04 +0000</pubDate>
		<dc:creator>Ammar Qammaz</dc:creator>
				<category><![CDATA[Post]]></category>
		<category><![CDATA[AmmarServer]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://ammar.gr/?p=520</guid>
		<description><![CDATA[For the last couple of days I have been implementing ETags on AmmarServer which seem to be a nice way for cache handshaking ( and work very well with my internal server side caching mechanism ) .. To profile my server&#8217;s behaviour I am using chromium and the very handy Developer Tools that come integrated [...]]]></description>
			<content:encoded><![CDATA[<p>For the last couple of days I have been implementing <a href="http://en.wikipedia.org/wiki/HTTP_ETag">ETags</a> on <a href="https://github.com/AmmarkoV/AmmarServer">AmmarServer</a> which seem to be a nice way for cache handshaking ( and work very well with my internal server side caching mechanism )   ..</p>
<p>To profile my server&#8217;s behaviour I am using chromium and the very handy Developer Tools that come integrated in it , Especially the Network Timeline feature is great for debugging this sort of things.. <a href="http://redbot.org/?uri=http%3A%2F%2Fammar.gr%3A8080%2F">RedBot is also a very useful tool!</a> that I use for debugging HTTP handshakes..</p>
<p>Although my implementation isn&#8217;t ready yet I am getting some very weird results when I emmit 304 Not Changed responses illustrated in the screenshots bellow ..!</p>
<p>The screenshots are that big due to my dual 1080p screen setup <img src='http://ammar.gr/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><a href="http://ammar.gr/wp-content/uploads/2012/10/apache_and_ammarserver_200_ok.png"><img src="http://ammar.gr/wp-content/uploads/2012/10/apache_and_ammarserver_200_ok-300x84.png" alt="Apache And AmmarServer both serving 200 OK responses.." title="Apache And AmmarServer both serving 200 OK responses.." width="300" height="84" class="alignnone size-medium wp-image-521" /></a></p>
<p><a href="http://ammar.gr/wp-content/uploads/2012/10/apache_and_ammarserver_304_and_200.png"><img src="http://ammar.gr/wp-content/uploads/2012/10/apache_and_ammarserver_304_and_200-300x84.png" alt="Apache and AmmarServer , AmmarServer emmiting 304 responses and Apache 200 OK " title="Apache and AmmarServer , AmmarServer emmiting 304 responses and Apache 200 OK " width="300" height="84" class="alignnone size-medium wp-image-522" /></a></p>
<p>I can&#8217;t seem to grasp the reason why a 304 response has such a large &#8220;Waiting Time&#8221; , Is it my Response header that is missing something , is it the whole  Keep Alive thing not being handled properly , or is the waiting time supposed to mean something else in the graph..<br />
How is it possible when only 200 byte headers get served that the response time is 4 times worse than when the full files get served from memory ?  </p>
<p>I haven&#8217;t still figured it out and it is driving me crazy , but I will get to the bottom of this <img src='http://ammar.gr/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ..  </p>
<p><strong>UPDATE </strong><br />
After some tweaking around and with the help of <a href="http://redbot.org/?uri=http%3A%2F%2Fammar.gr%3A8080%2F">redbot</a> it turns out that the 304 Not Modified header should retransmit all of the original fields transmitted with the first &#8220;200 OK&#8221; message.. This means all of the E-Tag , Date etc fields.. I was missing out some of them so including them fixed the behaviour.. </p>
]]></content:encoded>
			<wfw:commentRss>http://ammar.gr/?feed=rss2&#038;p=520</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing the raspberry pi as a webserver!</title>
		<link>http://ammar.gr/?p=502</link>
		<comments>http://ammar.gr/?p=502#comments</comments>
		<pubDate>Tue, 25 Sep 2012 00:35:03 +0000</pubDate>
		<dc:creator>Ammar Qammaz</dc:creator>
				<category><![CDATA[Post]]></category>
		<category><![CDATA[AmmarServer]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://ammar.gr/?p=502</guid>
		<description><![CDATA[My friend Philimon lent me his new raspberry pi after experiencing problems using the usb ports on the board.. After a little tinkering I found out that using a usb hub with an external power supply solved the issues and everything worked fine so his problems must have been power related with the pi not [...]]]></description>
			<content:encoded><![CDATA[<p>My friend Philimon lent me his new raspberry pi after experiencing problems using the usb ports on the board.. After a little tinkering I found out that using a usb hub with an external power supply solved the issues and everything worked fine so his problems must have been power related with the pi not supplying enough juice for the power hungry usb peripherals he connected.  </p>
<p>Having the opportunity to first-hand test the pi  I immediately apt-got git and <a href="https://github.com/AmmarkoV/AmmarServer">cloned my AmmarServer repo</a> to test it with the board <img src='http://ammar.gr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The results look very promising since the pi with ammarserver beats my current mini-itx intel atom based setup which is running the heavier apache webserver..</p>
<p>In more detail subsequently querying a static version of the the page you see right now ( as described in a previous post ) gave the following times..</p>
<p>Raspberry Pi using AmmarServer :<br />
00:00:02.64 <- first uncached try with actual sd read time ( also worth to note that a Class 10 sd card is used )<br />
00:00:00.706 <- rasp cached , no file reading involved<br />
00:00:00.787 <- rasp cached , no file reading involved<br />
00:00:00.818 <- rasp cached , no file reading involved<br />
00:00:00.833 <- rasp cached , no file reading involved<br />
00:00:00.788 <- rasp cached , no file reading involved<br />
00:00:00.810 <- rasp cached , no file reading involved</p>
<p>My current webserver using apache ( and dynamic content [ php/mysql/wordpress ] ) :<br />
00:00:02.802 <- ammar.gr with apache<br />
00:00:01.561 <- ammar.gr with apache (some images etc. cached probably) </p>
<p>My current webserver using AmmarServer ( and static saved pages ) :<br />
00:00:01.72 <- ammar.gr first uncached try with actual hd read time<br />
00:00:00.678 <- ammar.gr with ammarserver cached , no file reading involved<br />
00:00:00.652 <- ammar.gr with ammarserver cached , no file reading involved</p>
<p>As one can see the best times of the pi 00:00:00.706 are pretty damn close to the 00:00:00.652 of my current machine when the content is already cached in memory so I may be changing my web hosting setup soon..!</p>
<p>I will probably keep my current webserver as a platform to make dynamic webpages using the really nice GUI of wordpress and then pass static versions of them to the pi which will act as the always on webserver..<br />
An additional thing that I didn't test was performance using more processes like a mumble server, an ftp server or an actual php/apache setup but.. </p>
<p>When I'll order my own pi I will try all of them and blog back with my results..!</p>
<p><a href="http://ammar.gr/wp-content/uploads/2012/09/raspberry1.jpg"><img src="http://ammar.gr/wp-content/uploads/2012/09/raspberry1-300x252.jpg" alt="" title="raspberry1"  height="198" class="alignnone size-medium wp-image-503" /></a> <a href="http://ammar.gr/wp-content/uploads/2012/09/raspberry2.jpg"><img src="http://ammar.gr/wp-content/uploads/2012/09/raspberry2-300x198.jpg" alt="" title="raspberry2"  height="198" class="alignnone size-medium wp-image-504" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ammar.gr/?feed=rss2&#038;p=502</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
