<?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"
	>

<channel>
	<title>Clker.com - weblog</title>
	<atom:link href="http://www.clker.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clker.com/blog</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Mon, 12 May 2008 15:55:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Caching SQL results with PHP</title>
		<link>http://www.clker.com/blog/2008/05/12/caching-sql-results-with-php/</link>
		<comments>http://www.clker.com/blog/2008/05/12/caching-sql-results-with-php/#comments</comments>
		<pubDate>Mon, 12 May 2008 15:54:36 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[development]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[bench]]></category>

		<category><![CDATA[cache]]></category>

		<category><![CDATA[optimization]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[server]]></category>

		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2008/05/12/caching-sql-results-with-php/</guid>
		<description><![CDATA[I&#8217;ve been looking around lately on the best way to cache SQL results in PHP. I found some interesting articles posted in lots of places, but I didn&#8217;t find any that exactly matches my needs. The problem I have on hand is basically the same every growing website faces: decreasing mean resource usage per page [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking around lately on the best way to cache SQL results in PHP. I found some interesting articles posted in lots of places, but I didn&#8217;t find any that exactly matches my needs. The problem I have on hand is basically the same every growing website faces: decreasing mean resource usage per page request.</p>
<p><strong>Now - this is my plan A </strong>to keep up with the website&#8217;s growth without a lot of hardware upgrades. There is a plan B, but I will keep that to a later post.<br />
<span id="more-29"></span><br />
Usually, the time consumed by executing the SQL statements is more than 80% of the whole script time. Reducing this time will significantly reduce the resource usage. CPU is not the bottle neck, usually SQL queries result in a significant disk access especially if there&#8217;s a lot of inserts/updates/deletes.</p>
<p>The easiest and best way I found is to use PHP&#8217;s serialize to store the SQL results. This requires that we fetch all the rows we&#8217;re dealing with. So the sequence of operations is to check the cache file, if expired or does not exist then fetch all the rows from the result set, serialize in one variable, write it to the cache file.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">require_once</span> <span class="st0">&quot;utils.php&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$cache_prefix</span>=<span class="st0">&#8216;/tmp/clkercache/&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> cache_fetch<span class="br0">&#40;</span><span class="re0">$filename</span>, <span class="re0">$expiration</span>=<span class="nu0">3600</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <a href="http://www.php.net/global"><span class="kw3">global</span></a> <span class="re0">$cache_prefix</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$filename</span>=<span class="re0">$cache_prefix</span>.<span class="re0">$filename</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>!<a href="http://www.php.net/file_exists"><span class="kw3">file_exists</span></a><span class="br0">&#40;</span><span class="re0">$filename</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw1">return</span> <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/time"><span class="kw3">time</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>-<a href="http://www.php.net/filemtime"><span class="kw3">filemtime</span></a><span class="br0">&#40;</span><span class="re0">$filename</span><span class="br0">&#41;</span>&gt;<span class="re0">$expiration</span><span class="br0">&#41;</span> <span class="kw1">return</span> <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$data</span>=<a href="http://www.php.net/unserialize"><span class="kw3">unserialize</span></a><span class="br0">&#40;</span><a href="http://www.php.net/base64_decode"><span class="kw3">base64_decode</span></a><span class="br0">&#40;</span><a href="http://www.php.net/file_get_contents"><span class="kw3">file_get_contents</span></a><span class="br0">&#40;</span><span class="re0">$filename</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">return</span> <span class="re0">$data</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> cache_store<span class="br0">&#40;</span><span class="re0">$filename</span>,<span class="re0">$data</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <a href="http://www.php.net/global"><span class="kw3">global</span></a> <span class="re0">$cache_prefix</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$filename</span>=<span class="re0">$cache_prefix</span>.<span class="re0">$filename</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; @mk_dir<span class="br0">&#40;</span><span class="re0">$filename</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="kw1">return</span> file_put_contents<span class="br0">&#40;</span><span class="re0">$filename</span>,<a href="http://www.php.net/base64_encode"><span class="kw3">base64_encode</span></a><span class="br0">&#40;</span><a href="http://www.php.net/serialize"><span class="kw3">serialize</span></a><span class="br0">&#40;</span><span class="re0">$data</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>So the way to use the caching functions would be something similar to this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span> !<span class="br0">&#40;</span><span class="re0">$pictures</span>=cache_fetch<span class="br0">&#40;</span><span class="st0">&quot;mypictures.cache&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$res</span>=query<span class="br0">&#40;</span><span class="st0">&quot;select pictureid from pictures order by rating15days desc limit 100&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$row</span>=fetch_array<span class="br0">&#40;</span><span class="re0">$res</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="re0">$pictures</span><span class="br0">&#91;</span><span class="br0">&#93;</span>=<span class="re0">$row</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; cache_store<span class="br0">&#40;</span><span class="st0">&quot;mypictures.cache&quot;</span>,<span class="re0">$pictures</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>So how to do that if you have multiple queries? The way I store my cache files is by giving them suffix or prefix names depending on what is being stores. For example a file that store the pictures that are related to a picture whose id is 1500 being displayed, will be called <strong>related-1500.cache</strong>. For more complicated cases like searches, I would use the md5sum of the request URI.</p>
<p>The results were good. Using apache bench I tested the homepage. Before any caching it used to support 3 pages per second. After caching the result was 35. I think in my current situation with my current traffic, this is a very good result.</p>
<p>One might think so what does it take to generate pages at a much higher rate - say 300, 400 or even a 1000 or more? Well, that&#8217;s my plan B, and I&#8217;ll discuss that in more detail in another post. This plan B will generate that much pages per second.</p>
<p>Technorati Tags: <a href="#" rel="tag">optimization</a>, <a href="#" rel="tag"> server</a>, <a href="#" rel="tag"> sql</a>, <a href="#" rel="tag"> php</a>, <a href="#" rel="tag"> apache</a>, <a href="#" rel="tag"> bench</a>, <a href="#" rel="tag"> cache</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2008/05/12/caching-sql-results-with-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Gatner &#8220;Windows is collapsing&#8221;</title>
		<link>http://www.clker.com/blog/2008/04/11/gatner-windows-is-collapsing/</link>
		<comments>http://www.clker.com/blog/2008/04/11/gatner-windows-is-collapsing/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 15:28:17 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[apple]]></category>

		<category><![CDATA[crash]]></category>

		<category><![CDATA[embedded]]></category>

		<category><![CDATA[mac os]]></category>

		<category><![CDATA[microsoft]]></category>

		<category><![CDATA[operating system]]></category>

		<category><![CDATA[os x]]></category>

		<category><![CDATA[tivo]]></category>

		<category><![CDATA[vista]]></category>

		<category><![CDATA[windows]]></category>

		<category><![CDATA[windows xp]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2008/04/11/gatner-windows-is-collapsing/</guid>
		<description><![CDATA[So Gartner, one of the largest analysis companies said in a conference that windows is collapsing. Lots of reasons were given including a large code for windows that became un-maintainable and lead Microsoft to start from a more stable release of Windows 2003, and improve on for Vista. This in turn lead to Vista not [...]]]></description>
			<content:encoded><![CDATA[<p>So Gartner, one of the largest analysis companies said in a conference that <a href="http://www.techcrunch.com/2008/04/11/gartner-says-vista-will-collapse-and-thats-why-the-yahoo-deal-must-happen/trackback/">windows is collapsing</a>. Lots of reasons were given including a large code for windows that became un-maintainable and lead Microsoft to start from a more stable release of Windows 2003, and improve on for Vista. This in turn lead to Vista not really delivering meaningful enhancements from the point of view of the end consumer. Also, the fact that applications now are moving on the web and becoming OS agnostic where you can run many available software almost on all operating systems (openoffice for example, inkscape and others based on GNU&#8217;s compilers or java).</p>
<p>Other reasons included a hardware demanding OS, which can&#8217;t fit on small PDA&#8217;s and thus giving the chance for Linux and OS X. I add to this list, the complete prevalence of Linux in embedded OSs in appliances like Tivos, with zero competition from Microsoft.</p>
<p>A big major contribution from my point of view is the reason of making a new release. When a company decides to allocate resources for the development of a software, they need goals. The only goal that is obvious from the release of Vista was to duress people into DRM, using windows position as a must be OS on every PC or  laptop. A very important lesson that you can&#8217;t force the whole world into only your own vision, but you have to embrace what people want, make it your vision and may be add more on the side. After all people are the consumer. Unfortunately, that was the second time Microsoft did that, after they already suffered losses on the server side and hosting.</p>
<p>However, I do disagree with Gartner on the result that Microsoft or windows will crash. I believe that <a href="http://ajaxian.com/archives/getting-feedback-to-the-ie-8-team">Microsoft is trying to embrace</a> <a href="http://www.redhatmagazine.com/2008/04/10/ooxml-approved-by-iso-what-next/trackback/">the standards</a> and work with others, it&#8217;s just they&#8217;re not doing enough and lots of people doubt their intentions. My view is Microsoft becoming more like SUN or IBM where they will have to work with people and provide solutions for the problems that people see using ways that the people want.</p>
<p>Technorati Tags: <a href="#" rel="tag">microsoft</a>, <a href="#" rel="tag"> windows</a>, <a href="#" rel="tag"> crash</a>, <a href="#" rel="tag"> linux</a>, <a href="#" rel="tag"> apple</a>, <a href="#" rel="tag"> mac os</a>, <a href="#" rel="tag"> os x</a>, <a href="#" rel="tag"> tivo</a>, <a href="#" rel="tag"> embedded</a>, <a href="#" rel="tag"> operating system</a>, <a href="#" rel="tag"> vista</a>, <a href="#" rel="tag"> windows xp</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2008/04/11/gatner-windows-is-collapsing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Multiple SVG uploads</title>
		<link>http://www.clker.com/blog/2008/04/07/multiple-svg-uploads/</link>
		<comments>http://www.clker.com/blog/2008/04/07/multiple-svg-uploads/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 16:14:18 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[clker.com]]></category>

		<category><![CDATA[news]]></category>

		<category><![CDATA[clipart]]></category>

		<category><![CDATA[svg]]></category>

		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2008/04/07/multiple-svg-uploads/</guid>
		<description><![CDATA[Now you can upload multiple files at ones. Zip all your SVG images in one zip file, and upload the zip file. The upload page will then loop through all SVG files stores inside the zip, and will try to add them.  Upload limit is still 2MBytes.
Technorati Tags: clker.com,   svg,  clipart,  upload
]]></description>
			<content:encoded><![CDATA[<p>Now you can upload multiple files at ones. Zip all your SVG images in one zip file, and upload the zip file. The upload page will then loop through all SVG files stores inside the zip, and will try to add them.  Upload limit is still 2MBytes.</p>
<p>Technorati Tags: <a href="#" rel="tag">clker.com</a>, <a href="#" rel="tag">  svg</a>, <a href="#" rel="tag"> clipart</a>, <a href="#" rel="tag"> upload</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2008/04/07/multiple-svg-uploads/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating a tar gz on the fly using PHP</title>
		<link>http://www.clker.com/blog/2008/03/27/creating-a-tar-gz-on-the-fly-using-php/</link>
		<comments>http://www.clker.com/blog/2008/03/27/creating-a-tar-gz-on-the-fly-using-php/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 17:41:53 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[Internet general]]></category>

		<category><![CDATA[development]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[compress]]></category>

		<category><![CDATA[gz]]></category>

		<category><![CDATA[online]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2008/03/27/creating-a-tar-gz-on-the-fly-using-php/</guid>
		<description><![CDATA[A while ago, I thought about creating a tar.gz file for every download, so that if someone runs a search, he/she then can download all the images in the results. After a little bit of research, I found that PHP has a function for gzip. I also knew that the tar format just sticks files [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I thought about creating a tar.gz file for every download, so that if someone runs a search, he/she then can download all the images in the results. After a little bit of research, I found that PHP has a function for gzip. I also knew that the tar format just sticks files after one another, so if I can implement the tar format in PHP then I can gzip all images in the results.</p>
<p>I found <a href="http://www.koders.com/php/fidA384A1E097E7BEA8DB56698D0FE248C7E1D68DB4.aspx?s=smtp+server">this LGPL code</a> that implemented the tar format. I used it (and modified it a little bit) to produce the online tar.gz functions:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// Computes the unsigned Checksum of a file&#8217;s header</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// to try to ensure valid file</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// PRIVATE ACCESS FUNCTION</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> __computeUnsignedChecksum<span class="br0">&#40;</span><span class="re0">$bytestring</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span>=<span class="nu0">0</span>; <span class="re0">$i</span>&lt;<span class="nu0">512</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$unsigned_chksum</span> += <a href="http://www.php.net/ord"><span class="kw3">ord</span></a><span class="br0">&#40;</span><span class="re0">$bytestring</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span>=<span class="nu0">0</span>; <span class="re0">$i</span>&lt;<span class="nu0">8</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$unsigned_chksum</span> -= <a href="http://www.php.net/ord"><span class="kw3">ord</span></a><span class="br0">&#40;</span><span class="re0">$bytestring</span><span class="br0">&#91;</span><span class="nu0">148</span> + <span class="re0">$i</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="re0">$unsigned_chksum</span> += <a href="http://www.php.net/ord"><span class="kw3">ord</span></a><span class="br0">&#40;</span><span class="st0">&quot; &quot;</span><span class="br0">&#41;</span> * <span class="nu0">8</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">return</span> <span class="re0">$unsigned_chksum</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// Generates a TAR file from the processed data</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// PRIVATE ACCESS FUNCTION</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> tarSection<span class="br0">&#40;</span><span class="re0">$Name</span>, <span class="re0">$Data</span>, <span class="re0">$information</span>=<span class="kw2">NULL</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Generate the TAR header for this file</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><span class="re0">$Name</span>,<span class="nu0">100</span>,<a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><span class="st0">&quot;777&quot;</span>,<span class="nu0">7</span>,<span class="st0">&quot;0&quot;</span>,STR_PAD_LEFT<span class="br0">&#41;</span> . <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><a href="http://www.php.net/decoct"><span class="kw3">decoct</span></a><span class="br0">&#40;</span><span class="re0">$information</span><span class="br0">&#91;</span><span class="st0">&quot;user_id&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>,<span class="nu0">7</span>,<span class="st0">&quot;0&quot;</span>,STR_PAD_LEFT<span class="br0">&#41;</span> . <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><a href="http://www.php.net/decoct"><span class="kw3">decoct</span></a><span class="br0">&#40;</span><span class="re0">$information</span><span class="br0">&#91;</span><span class="st0">&quot;group_id&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>,<span class="nu0">7</span>,<span class="st0">&quot;0&quot;</span>,STR_PAD_LEFT<span class="br0">&#41;</span> . <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><a href="http://www.php.net/decoct"><span class="kw3">decoct</span></a><span class="br0">&#40;</span><a href="http://www.php.net/strlen"><span class="kw3">strlen</span></a><span class="br0">&#40;</span><span class="re0">$Data</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,<span class="nu0">11</span>,<span class="st0">&quot;0&quot;</span>,STR_PAD_LEFT<span class="br0">&#41;</span> . <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><a href="http://www.php.net/decoct"><span class="kw3">decoct</span></a><span class="br0">&#40;</span><a href="http://www.php.net/time"><span class="kw3">time</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,<span class="nu0">11</span>,<span class="st0">&quot;0&quot;</span>,STR_PAD_LEFT<span class="br0">&#41;</span> . <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_repeat"><span class="kw3">str_repeat</span></a><span class="br0">&#40;</span><span class="st0">&quot; &quot;</span>,<span class="nu0">8</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <span class="st0">&quot;0&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_repeat"><span class="kw3">str_repeat</span></a><span class="br0">&#40;</span><a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>,<span class="nu0">100</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><span class="st0">&quot;ustar&quot;</span>,<span class="nu0">6</span>,<a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">32</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">32</span><span class="br0">&#41;</span> . <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><span class="re0">$information</span><span class="br0">&#91;</span><span class="st0">&quot;user_name&quot;</span><span class="br0">&#93;</span>,<span class="nu0">32</span>,<a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><span class="re0">$information</span><span class="br0">&#91;</span><span class="st0">&quot;group_name&quot;</span><span class="br0">&#93;</span>,<span class="nu0">32</span>,<a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_repeat"><span class="kw3">str_repeat</span></a><span class="br0">&#40;</span><a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>,<span class="nu0">8</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_repeat"><span class="kw3">str_repeat</span></a><span class="br0">&#40;</span><a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>,<span class="nu0">8</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_repeat"><span class="kw3">str_repeat</span></a><span class="br0">&#40;</span><a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>,<span class="nu0">155</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span> .= <a href="http://www.php.net/str_repeat"><span class="kw3">str_repeat</span></a><span class="br0">&#40;</span><a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>,<span class="nu0">12</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Compute header checksum</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="re0">$checksum</span> = <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><a href="http://www.php.net/decoct"><span class="kw3">decoct</span></a><span class="br0">&#40;</span>__computeUnsignedChecksum<span class="br0">&#40;</span><span class="re0">$header</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,<span class="nu0">6</span>,<span class="st0">&quot;0&quot;</span>,STR_PAD_LEFT<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span>=<span class="nu0">0</span>; <span class="re0">$i</span>&lt;<span class="nu0">6</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$header</span><span class="br0">&#91;</span><span class="br0">&#40;</span><span class="nu0">148</span> + <span class="re0">$i</span><span class="br0">&#41;</span><span class="br0">&#93;</span> = <a href="http://www.php.net/substr"><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$checksum</span>,<span class="re0">$i</span>,<span class="nu0">1</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$header</span><span class="br0">&#91;</span><span class="nu0">154</span><span class="br0">&#93;</span> = <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="re0">$header</span><span class="br0">&#91;</span><span class="nu0">155</span><span class="br0">&#93;</span> = <a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">32</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// Pad file contents to byte count divisible by 512</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$file_contents</span> = <a href="http://www.php.net/str_pad"><span class="kw3">str_pad</span></a><span class="br0">&#40;</span><span class="re0">$Data</span>,<span class="br0">&#40;</span><a href="http://www.php.net/ceil"><span class="kw3">ceil</span></a><span class="br0">&#40;</span><a href="http://www.php.net/strlen"><span class="kw3">strlen</span></a><span class="br0">&#40;</span><span class="re0">$Data</span><span class="br0">&#41;</span> / <span class="nu0">512</span><span class="br0">&#41;</span> * <span class="nu0">512</span><span class="br0">&#41;</span>,<a href="http://www.php.net/chr"><span class="kw3">chr</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="co1">// Add new tar formatted data to tar file contents</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$tar_file</span> = <span class="re0">$header</span> . <span class="re0">$file_contents</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">return</span> <span class="re0">$tar_file</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> targz<span class="br0">&#40;</span><span class="re0">$Name</span>, <span class="re0">$Data</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">return</span> <a href="http://www.php.net/gzencode"><span class="kw3">gzencode</span></a><span class="br0">&#40;</span>tarSection<span class="br0">&#40;</span><span class="re0">$Name</span>,<span class="re0">$Data</span><span class="br0">&#41;</span>,<span class="nu0">9</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>To  use those functions all you have to do is send a header with the mime type for the tar gz ( application/x-gzi<span id="__firefox-findbar-search-id" style="padding: 0pt; background-color: yellow; color: black; display: inline; font-size: inherit"></span>p ) using the php header function. To add a tar/gz section for a file, read the file in an array using filegetcontents and pass the filename and data to the targz function. Echo what is returned. That&#8217;s it!</p>
<p>So why is it not active on clker.com website? I actually tried it and found that compression consumes a lot of CPU. In the first 20 minute I had more than one hundred connections for different users downloading their results and the CPU was saturated. This basically left no CPU for searching. So use it carefully, and only if you really need that functionality.</p>
<p>Technorati Tags: <a href="#" rel="tag">tar</a>, <a href="#" rel="tag"> gz</a>, <a href="#" rel="tag"> compress</a>, <a href="#" rel="tag"> online</a>, <a href="#" rel="tag"> php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2008/03/27/creating-a-tar-gz-on-the-fly-using-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Website updates</title>
		<link>http://www.clker.com/blog/2008/03/05/website-updates/</link>
		<comments>http://www.clker.com/blog/2008/03/05/website-updates/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 17:15:15 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[clker.com]]></category>

		<category><![CDATA[colors]]></category>

		<category><![CDATA[theme]]></category>

		<category><![CDATA[update]]></category>

		<category><![CDATA[website]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2008/03/05/website-updates/</guid>
		<description><![CDATA[I&#8217;ve been recently working on the website theme, colors both on the weblog side and the main website&#8217;s side. I believe it looks much nicer and less crowded this way. I will be synchronizing the style sheet of Wordpress and the website&#8217;s main part so that visitors and users won&#8217;t feel they&#8217;ve moved into a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been recently working on the website theme, colors both on the weblog side and the main website&#8217;s side. I believe it looks much nicer and less crowded this way. I will be synchronizing the style sheet of Wordpress and the website&#8217;s main part so that visitors and users won&#8217;t feel they&#8217;ve moved into a different place.</p>
<p>I also added a <a href="http://www.clker.com/privacy-policy.html">privacy policy</a> page, still have to link that to the footer of the blog. Sometimes, after commits and updates some functionalities are broken. I will be checking and testing around the website to make sure everything still works. You can leave a comment here if you face.</p>
<p>I&#8217;ve been experimenting spatial image querying lately. Hopefully, below every image spatially similar ones will be showing soon regardless whether they were tagged or no. There&#8217;s a lot of work involved here, and hopefully I will roll out soon at least some experimental version to see how users react to it.</p>
<p>Technorati Tags: <a href="#" rel="tag">website</a>, <a href="#" rel="tag"> theme</a>, <a href="#" rel="tag"> wordpress</a>, <a href="#" rel="tag"> update</a>, <a href="#" rel="tag"> colors</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2008/03/05/website-updates/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Storing images in your sql database versus filesystem</title>
		<link>http://www.clker.com/blog/2008/03/03/storing-images-in-your-sql-database-versus-filesystem/</link>
		<comments>http://www.clker.com/blog/2008/03/03/storing-images-in-your-sql-database-versus-filesystem/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 04:56:10 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[Internet general]]></category>

		<category><![CDATA[development]]></category>

		<category><![CDATA[access speed]]></category>

		<category><![CDATA[binary storage]]></category>

		<category><![CDATA[database server]]></category>

		<category><![CDATA[file system]]></category>

		<category><![CDATA[images]]></category>

		<category><![CDATA[pictures]]></category>

		<category><![CDATA[sql server]]></category>

		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2008/03/03/storing-images-in-your-sql-database-versus-filesystem/</guid>
		<description><![CDATA[Many websites today rely on media be it images or videos. One reason is humans are visual creatures, they like seeing things versus reading long articles.
Images on websites can be divided into two different types: Images used in the website theme including logos, rounded corners, backgrounds &#8230;etc. and images used as content. Obviously, the ones [...]]]></description>
			<content:encoded><![CDATA[<p>Many websites today rely on media be it images or videos. One reason is humans are visual creatures, they like seeing things versus reading long articles.</p>
<p>Images on websites can be divided into two different types: Images used in the website theme including logos, rounded corners, backgrounds &#8230;etc. and images used as content. Obviously, the ones discussed here are the content images. Images used in the website theme will be accessed frequently and almost with every page view, and usually they are very few and better managed by storing them in a directory.</p>
<p><span id="more-24"></span>However, when dealing with images that build the content of the websites developers will tend sometimes to store them in their sql databases rather than just storing references to them. There are pros and cons for each approach:</p>
<p><strong>Storing the images outside the database:</strong></p>
<p>For a very long time, this approach has been considered the most appropriate approach. The binaries itself gets stores outside the database, while references are stored inside the database. This type of implementation is driven by the ideas that:</p>
<ol>
<li>It will be faster to access images off the hard drives, than through the database.</li>
<li>It will take less space, since the database servers will usually add more records for locking and several other extra functionalities.</li>
</ol>
<p>While actually true, problems start once the number of images grow. Although one can maintain referential integrity inside the database, there is nothing that will stop an image from being deleted from the directory structure. Also, nothing will stop and image from being deleted while its record still exists in the database resulting in dangling pointers.</p>
<p>A third and more serious problem is enforcing access rules. One of the biggest implementers of this approach is the famous image sharing website flickr.com . Flickr uses mysql to store image pointers, while the images itself are stored on disk and can be accessed through the lighthttpd server. While flickr enforces several rules to filter the pictures returned in its search results using geographic and login usernames/password any image can be viewed without logging in using its URL regardless of the fact that it needs to be filtered.</p>
<p><strong>Storing images inside the sql database server:</strong></p>
<p>That approach solves the previous problems. Since the image is stored inside the database:</p>
<ol>
<li>Authentication and access rights can be verified before the image is returned.</li>
<li>On the fly thumbnails can be created thus more space saved.</li>
<li>Referential integrity can be maintained.</li>
<li>Cascaded deletions can be implemented. So when a user deletes an album, all the images inside the album will also be deleted.</li>
<li>The whole application will be less complex.</li>
</ol>
<p>Database engines use several types to store binary data. Postgresql uses byta, mysql uses blob types. Both achieve the same objective of storing binary object. This approach has its own problems as well. The database will now occupy a larger portion of the hard drive, larger than the size of the binary images itself. Retrieving the images will be slightly slower. My experiments in my other website (mibrahim.net) showed that retrieving images from postgresql was actually not bad, and for users accessing the website they won&#8217;t even feel the difference. One major disadvantage is database backup/restore. Since the size of the database is larger, dumping the database for backup can sometimes take days. If you are using WALs then most likely your WALs will be bloated and big from binary inserts. Bottom line, you&#8217;ll gain a lot but you&#8217;ll have to pay more money and buy larger drives to store the larger data.</p>
<p>There is a nice article written <a href="http://www.oracle.com/technology/products/intermedia/htdocs/why_images_in_database.html">by Oracle having more details about this issue</a>.</p>
<p>So in terms of clker.com, this is a planned functionality - to move all images and pictures inside the postgresql database. I believe that my server has the cpu and HD cycles to carry this load, and I know from my previous experience it will definitely help in decreasing the complications I have now.</p>
<p>Technorati Tags: <a href="#" rel="tag">images</a>, <a href="#" rel="tag"> pictures</a>, <a href="#" rel="tag"> binary storage</a>, <a href="#" rel="tag"> database server</a>, <a href="#" rel="tag"> sql server</a>, <a href="#" rel="tag"> storage</a>, <a href="#" rel="tag"> file system</a>, <a href="#" rel="tag"> access speed</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2008/03/03/storing-images-in-your-sql-database-versus-filesystem/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Running your server is easy, fun but involved</title>
		<link>http://www.clker.com/blog/2008/03/01/running-your-server-is-easy-fun-but-involved/</link>
		<comments>http://www.clker.com/blog/2008/03/01/running-your-server-is-easy-fun-but-involved/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 01:09:09 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[Internet general]]></category>

		<category><![CDATA[development]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[server]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[database]]></category>

		<category><![CDATA[database server]]></category>

		<category><![CDATA[sql server]]></category>

		<category><![CDATA[ubuntu]]></category>

		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2008/03/01/running-your-server-is-easy-fun-but-involved/</guid>
		<description><![CDATA[I love using Linux to do my work. My best usage of Linux is my web server, although I recall I read once that Linus never intended for the kernel to be used as a server. He was more focused on using the kernel in desktops. I&#8217;ve been running my own web server for almost [...]]]></description>
			<content:encoded><![CDATA[<p>I love using Linux to do my work. My best usage of Linux is my web server, although I recall I read once that Linus never intended for the kernel to be used as a server. He was more focused on using the kernel in desktops. I&#8217;ve been running my own web server for almost a year now, which runs two websites mibrahim.net my real estate website, and clker.com a to be online clipart website - we&#8217;re halfway there.</p>
<p>The fun part is simply everything just works. You&#8217;ll have all the tools you need starting from database engines like postgres, mysql to scripting languages like php, ruby with different types of webservers apache, lighthttpd and others. All the tools you might think of are there and under your own hand. Building your own server is not expensive - around $100 will do it. You don&#8217;t need a super quad core machine to produce extremely fast websites, unless you are already getting more than 50 page requests per second and at that point you will need something faster.</p>
<p>The performance bottle neck is never the CPU, it&#8217;s the hard drives read or write speeds. You can improve on that using fake RAIDs. Almost all Linux distros offer fake RAIDs and that is the cheapest way to improve the read speed.</p>
<p>Setting up your server is not a hard process. The best distributions that I recommend are Debian and Ubuntu. The reason is the very large library of software that comes with each. I believe that now the full distribution has grown more than 11 CDs. I used to run Debian and switched to Ubuntu a year ago and the reason behind the switch is the faster updates I get from Ubuntu, which enables me to use more recent and updated versions of PHP and the database engines.</p>
<p>The easiest setup is using the Ubuntu server CD, which is not any different from the desktop CD in terms of binaries. The only difference is that it won&#8217;t install the X11-server (GUI) and the window managers (gnome or kde) and the install program itself runs over the console and not VGA graphics. I use the server installation, and connect to my server using ssh. I have another old machine that runs Ubutu as well, and is used to run freenx. By that way I keep the server&#8217;s memory for the services running, and I can add all the GUI programs I want on this old machine.</p>
<p>Since I greatly benefited from running my own web server, I will share my experiences every now and then when I&#8217;ve got time to write.</p>
<p>Technorati Tags: <a href="#" rel="tag">ubuntu</a>, <a href="#" rel="tag"> linux</a>, <a href="#" rel="tag"> server</a>, <a href="#" rel="tag"> apache</a>, <a href="#" rel="tag"> database</a>, <a href="#" rel="tag"> sql server</a>, <a href="#" rel="tag"> database server</a>, <a href="#" rel="tag"> web server</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2008/03/01/running-your-server-is-easy-fun-but-involved/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hardware problems - the mystery solved</title>
		<link>http://www.clker.com/blog/2007/12/11/hardware-problems-the-mystery-solved/</link>
		<comments>http://www.clker.com/blog/2007/12/11/hardware-problems-the-mystery-solved/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 18:34:54 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[AMD]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[performance]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[postgresql]]></category>

		<category><![CDATA[sempron]]></category>

		<category><![CDATA[server]]></category>

		<category><![CDATA[shutting down]]></category>

		<category><![CDATA[temperature]]></category>

		<category><![CDATA[ubuntu]]></category>

		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2007/12/11/hardware-problems-the-mystery-solved/</guid>
		<description><![CDATA[I previously wrote about hardware problems that were puzzling me, and I finally found the answer. I installed sensors on ubuntu and ran ksensors and just watched what&#8217;s going on. The old server that was shutting down suddenly had an opteron dual core processor, which ran at 50 degrees Celsius at no load. I had [...]]]></description>
			<content:encoded><![CDATA[<p>I previously wrote about <a href="http://www.clker.com/blog/2007/12/08/hardware-problems/">hardware problems</a> that were puzzling me, and I finally found the answer. I installed sensors on ubuntu and ran ksensors and just watched what&#8217;s going on. The old server that was shutting down suddenly had an opteron dual core processor, which ran at 50 degrees Celsius at no load. I had three websites running there, the most recent addition is clker.com . Due to the large number of people that were trying to access the website, the CPU was loaded and overheated, which inturn lead to it shutting down.</p>
<p>Of course the solution is to put the server in a very cold room, which I don&#8217;t have. I resorted to buying a new board and CPU, which does not heat as much as the old ones and transfered the database and pictures to it. Currently the no load temperature is 11 degrees, which I think is great. This new board is a special sale from microcenter, both the board and CPU were for $94 with $15 rebate Sempron 64! I added 1GB of RAM. It really worked much better than my expectations, as I had very very low performance expectations from that CPU</p>
<p>Currently this server is running clker.com only, and will run mibrahim.net today. The CPU load as shown in top does not pass 2% except in spikes. People are still digging as well as search engine robots. So that&#8217;s a good value if someone wants to run his/her own starter website.</p>
<p>Technorati Tags: <a href="#" rel="tag">ubuntu</a>, <a href="#" rel="tag"> shutting down</a>, <a href="#" rel="tag"> temperature</a>, <a href="#" rel="tag"> sempron</a>, <a href="#" rel="tag"> AMD</a>, <a href="#" rel="tag"> performance</a>, <a href="#" rel="tag"> linux</a>, <a href="#" rel="tag"> web server</a>, <a href="#" rel="tag"> server</a>, <a href="#" rel="tag"> php</a>, <a href="#" rel="tag"> postgresql</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2007/12/11/hardware-problems-the-mystery-solved/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hardware problems</title>
		<link>http://www.clker.com/blog/2007/12/08/hardware-problems/</link>
		<comments>http://www.clker.com/blog/2007/12/08/hardware-problems/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 20:37:37 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[clker.com]]></category>

		<category><![CDATA[clker]]></category>

		<category><![CDATA[failures]]></category>

		<category><![CDATA[grub]]></category>

		<category><![CDATA[hardware]]></category>

		<category><![CDATA[power supply]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2007/12/08/hardware-problems/</guid>
		<description><![CDATA[The web server has been shutting down by itself for the past week. I tried looking at the logs to figure out why I come to my office and I find it turned off. It looks like there&#8217;s a hardware problem causing the server to shutdown suddenly.
Luckily, I didn&#8217;t get any database corruptions - not [...]]]></description>
			<content:encoded><![CDATA[<p>The web server has been shutting down by itself for the past week. I tried looking at the logs to figure out why I come to my office and I find it turned off. It looks like there&#8217;s a hardware problem causing the server to shutdown suddenly.</p>
<p>Luckily, I didn&#8217;t get any database corruptions - not until now. I changed the power supply and testing to see the results. In my experience almost 90% of the time it is a power supply problem especially that I&#8217;m loading the server with an extra useless PATA hard drive just to make GRUB happy.</p>
<p>Technorati Tags: <a href="#" rel="tag">grub</a>, <a href="#" rel="tag"> hardware</a>, <a href="#" rel="tag"> failures</a>, <a href="#" rel="tag"> clker</a>, <a href="#" rel="tag"> clker.com</a>, <a href="#" rel="tag"> power supply</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2007/12/08/hardware-problems/feed/</wfw:commentRss>
		</item>
		<item>
		<title>v0.1 Beta release of openoffice.org addon</title>
		<link>http://www.clker.com/blog/2007/11/30/beta-release-of-openofficeorg-addon/</link>
		<comments>http://www.clker.com/blog/2007/11/30/beta-release-of-openofficeorg-addon/#comments</comments>
		<pubDate>Fri, 30 Nov 2007 09:35:43 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim</dc:creator>
		
		<category><![CDATA[clker.com]]></category>

		<category><![CDATA[news]]></category>

		<category><![CDATA[openoffice.org]]></category>

		<category><![CDATA[plugins &amp; extensions]]></category>

		<category><![CDATA[addon]]></category>

		<category><![CDATA[clipart]]></category>

		<category><![CDATA[clker]]></category>

		<category><![CDATA[gallery]]></category>

		<category><![CDATA[online]]></category>

		<category><![CDATA[openoffice]]></category>

		<category><![CDATA[uno]]></category>

		<guid isPermaLink="false">http://www.clker.com/blog/2007/11/30/beta-release-of-openofficeorg-addon/</guid>
		<description><![CDATA[Finally, there&#8217;s a light at the end of the tunnel. It&#8217;s 4:21 AM and I&#8217;m very happy to reach this stage with the openoffice addon.
You can download it Openoffice.org addon for clker.com integration . Installation is very easy, from the tools menu in openoffice, select Extension Manager. Click add, and point to the file. You [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, there&#8217;s a light at the end of the tunnel. It&#8217;s 4:21 AM and I&#8217;m very happy to reach this stage with the openoffice addon.</p>
<p>You can download it <a href="http://www.clker.com/blog/wp-content/uploads/2007/11/clker.oxt" title="Openoffice.org addon for clker.com integration">Openoffice.org addon for clker.com integration</a> . Installation is very easy, from the tools menu in openoffice, select Extension Manager. Click add, and point to the file. You will need to restart openoffice for it to work.</p>
<p><a href="http://www.clker.com/blog/wp-content/uploads/2007/11/clker.png" title="openoffice.org addon screenshot"></p>
<p style="text-align: center"><img src="http://www.clker.com/blog/wp-content/uploads/2007/11/clker.thumbnail.png" alt="openoffice.org addon screenshot" /></p>
<p></a></p>
<p>This extension will show you the contents of your basket stored on clker, and will allow you to place any clipart image in the clipboard, then you can paste it in the correct place in your document.</p>
<p>Still there are some minor issues:</p>
<ol>
<li>The addon  parent is currently null, so an extra window will appear in the task bar</li>
<li>The way we place the picture in the clipboard is by loading it in draw, select all and copy then closing draw. There are better ways for doing this. You will notice that the screen will flicker especially if your using the ODG or the SVG formats since draw takes some time to render the vectors.</li>
</ol>
<p>In case you wanted to play with the source, the <a href="http://www.clker.com/blog/wp-content/uploads/2007/11/clker.zip" title="addon source">addon source is here.</a></p>
<p>Technorati Tags: <a href="#" rel="tag">addon</a>, <a href="#" rel="tag"> uno</a>, <a href="#" rel="tag"> openoffice</a>, <a href="#" rel="tag"> gallery</a>, <a href="#" rel="tag"> clipart</a>, <a href="#" rel="tag"> online</a>, <a href="#" rel="tag"> clker</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clker.com/blog/2007/11/30/beta-release-of-openofficeorg-addon/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
