<?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>that Sam guy &#187; mysql</title>
	<atom:link href="http://thatsamguy.com/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://thatsamguy.com</link>
	<description>Ramblings on tech and stuff</description>
	<lastBuildDate>Sat, 24 Sep 2011 08:07:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Upgrade to Sphinx and PBXT for ZuFeed.com</title>
		<link>http://thatsamguy.com/2011/09/upgrade-sphinx-pbxt-zufeed-com/</link>
		<comments>http://thatsamguy.com/2011/09/upgrade-sphinx-pbxt-zufeed-com/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 08:03:23 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Servers]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[ZuFeed]]></category>
		<category><![CDATA[fulltext]]></category>
		<category><![CDATA[myisam]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[pbxt]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://thatsamguy.com/?p=244</guid>
		<description><![CDATA[Although ZuFeed has been up and running for almost 2 years now, those who use it regularly (especially me) will have noticed that sometimes searches and collections time out and not load at all. Other times a collection may take 30 seconds to load. Never fear! A solution is at hand! What went wrong The [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://zufeed.com"><img class="alignright" title="ZuFeed" src="http://zufeed.com/logo50.png" alt="ZuFeed" width="196" height="80" /></a>Although <a title="ZuFeed - Latest news, updates and information from all over the world " href="http://zufeed.com">ZuFeed</a> has been up and running for almost 2 years now, those who use it regularly (especially me) will have noticed that sometimes searches and collections time out and not load at all. Other times a collection may take 30 seconds to load.</p>
<p>Never fear! A solution is at hand!</p>
<p><span id="more-244"></span></p>
<h3>
What went wrong</h3>
<p>The cause of these problems has been the architecture running behind ZuFeed. Although I designed much of the backend to scale greatly, history now shows that one major decision was incorrect&#8230; well at least is now incorrect for a site holding more than 3.3 million articles.</p>
<p>As ZuFeed uses MySQL as a backend, and fulltext searching is required, the original decision was to hold all the data in <a title="MyISAM - wikipedia entry" href="http://en.wikipedia.org/wiki/Myisam" target="_blank">MyISAM</a> tables and search using the built-in fulltext search indexes. As ZuFeed has grown searches have become a lot slower and new articles are added only seconds apart. This is due to two issues with using MyISAM and one coding error on my part.</p>
<ol>
<li>Poor scaling of MyISAM fulltext searching (for a database of 7GB+ in size)</li>
<li>Constant MyISAM table level locking for each new article entry</li>
<li>A missing index for the top searches</li>
</ol>
<h3>The Solution</h3>
<p><a href="http://primebase.org"><img class="alignright" title="PBXT" src="http://www.primebase.net/images/pbt_logo.jpg" alt="PrimeBase XT (PBST)" width="213" height="69" /></a>The third problem was easily solved by identifying the needed index and adding it to the database. Result? The search summary page now shows up without delays.</p>
<p>Solving the second problem required changing the storage engine to one that used row-level locking instead of table-level locking. The easiest options available were <a title="InnoDB wikipedia entry" href="http://en.wikipedia.org/wiki/InnoDB" target="_blank">InnoDB</a> and <a title="PBXT - PrimeBase XT" href="http://primebase.org/" target="_blank">PBXT</a>. Unlike InnoDB, PBXT is not included by default in MySQL installations and is instead available as a plugin. <a title="MariaDB - A drop in replacement for MySQL" href="http://mariadb.org/" target="_blank">MariaDB</a> (a fork of MySQL) however does include PBXT.</p>
<p>Both InnoDB and PBXT are robust, tranactional and ACID compliant storage engines. However PBXT is also log based, which allows for fast speed in a large variety of scenarios. As I have been using PBXT for a while now in another project, I decided to switch the tables to PBXT.</p>
<p>Since PBXT (and InnoDB) for that matter do not include fulltext searching, I needed a replacement search engine. I decided to use another open source project with a simple setup and very fast search speeds and easy integration with MySQL and php &#8211; <a title="Sphinx Fulltext Search Engine" href="http://sphinxsearch.com/about/sphinx/" target="_blank">Sphinx</a>.</p>
<h3>The Implementation</h3>
<p>I attempted to have as little down time as possible with the testing and then implementation of the new systems. Overall it went something like this:</p>
<p><strong><a href="http://sphinxsearch.com"><img class="alignright" title="Sphinx" src="http://sphinxsearch.com/images/sphinx.jpg" alt="Sphinx - Open Source Search Server" width="200" height="51" /></a>Part 1 &#8211; Sphinx Search Engine</strong></p>
<ul>
<li>Add a new auto incremented unique id of type integer to the databases (as required for Sphinx)</li>
<li>Set up Sphinx to use two indexes &#8211; one main and one delta for updates to allow shorter <a title="Sphinx Manual on Live Updates" href="http://sphinxsearch.com/docs/manual-0.9.8.html#live-updates" target="_blank">re-indexing</a> times (although not quite realtime)</li>
<li>Schedule delta index re-indexing every 60 seconds via a cron job.</li>
<li>Run initial indexing of article database &#8211; Warning! This can take long time!</li>
<li>Test Sphinx vs MySQL fulltext results via php.</li>
</ul>
<p>The results showed significantly faster searches using Sphinx over the MySQL in-built fulltext search. Sphinx also allowed more information to be searched. I was now able to include summary, author and permalink url fields to the search without penalty.</p>
<p><strong>Part 2 &#8211; Integrate Sphinx into ZuFeed</strong></p>
<ul>
<li>Change php classes to use Sphinx instead of MySQL fulltext searching</li>
<li>Add unique id conversion functions between new and old id&#8217;s</li>
<li>Maintain the same API to avoid changing other code</li>
<li>Test to make sure searching still works in ZuFeed</li>
</ul>
<p><strong>Part 3 &#8211; MyISAM to PBXT Conversion</strong></p>
<ul>
<li>Remove fulltext indexes from each table</li>
<li>Convert each table to use PBXT</li>
</ul>
<p>When converting a table from one storage engine to another, keep in mind that ALL data has to be copied to a new temporary table first, then renamed to remove the original. As such this takes a long time for multi-gigabytes tables.</p>
<h3>Conclusion</h3>
<p>And there you have it.</p>
<p><a title="ZuFeed - Latest news, updates and information from all over the world" href="http://zufeed.com/">ZuFeed</a> is now quicker at searching, responds to new requests faster, no longer times out on loading, and also produces more relevant results.</p>
]]></content:encoded>
			<wfw:commentRss>http://thatsamguy.com/2011/09/upgrade-sphinx-pbxt-zufeed-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New server (with photos)</title>
		<link>http://thatsamguy.com/2009/09/new-server-with-photos/</link>
		<comments>http://thatsamguy.com/2009/09/new-server-with-photos/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 12:47:09 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Cyprix]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mandriva]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[ZuFeed]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[intel]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[powerdns]]></category>
		<category><![CDATA[roundcube]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.cyprix.com.au/?p=82</guid>
		<description><![CDATA[As part of an overall upgrade for my systems, I&#8217;m moving to a brand new server. It&#8217;s my first rackmount server at 1U high and will be going into a colocation centre soonish. It will be running a variety of applications including: Mandriva Linux 2010.0 Web Serving: Nginx, Apache 2.2, PHP 5.3 Mail: Postfix, Dovecot, [...]]]></description>
			<content:encoded><![CDATA[<p>As part of an overall upgrade for my systems, I&#8217;m moving to a brand new server. It&#8217;s my first rackmount server at 1U high and will be going into a colocation centre soonish.</p>
<p>It will be running a variety of applications including:</p>
<ul>
<li>Mandriva Linux 2010.0</li>
<li>Web Serving: Nginx, Apache 2.2, PHP 5.3</li>
<li>Mail: Postfix, Dovecot, RoundCube</li>
<li>DNS: PowerDNS, Bind</li>
<li>Database: MySQL</li>
<li>Virtual Hosting: VirtualBox</li>
</ul>
<p>Server Specifications:</p>
<ul>
<li>Intel SR1530HSH with S3200SHVL Motherboard. 320w PSU, 3x Hot Swap SATA HDD, 2x Gb Nic</li>
<li><span style="text-decoration: line-through">Intel Q9550 Processor &#8211; 4x 2.83ghz, 12mb cache, e0 stepping</span></li>
<li>Intel Q9400 Processor &#8211; 4x 2.66ghz, 6mb cache, r0 stepping</li>
<li>4x 2gb (8gb total) Kingston DDR2 800Mhz Ram</li>
<li>2x 1Tb Seagate Hard Drives (in RAID 1)</li>
</ul>
<p><strong>Update:</strong> Unfortunately, the E0 stepping Q9550 is not supported for the bios of the s3200 motherboard, so I&#8217;ve had to switch down to the Q9400 with only 6mb cache <img src='http://thatsamguy.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> .</p>
<p>Photos:</p>
<div id="attachment_73" class="wp-caption alignleft" style="width: 260px"><img class="size-full wp-image-73" title="Intel SR1530HSH 1U Server - Front" src="http://blog.cyprix.com.au/wp-content/uploads/2009/09/23092009884th.jpg" alt="Intel SR1530HSH 1U Server - Front" width="250" height="188" /><p class="wp-caption-text">Intel SR1530HSH 1U Server - Front</p></div>
<div id="attachment_77" class="wp-caption alignleft" style="width: 260px"><img class="size-full wp-image-77" title="Intel SR1530HSH 1U Server - Rear" src="http://blog.cyprix.com.au/wp-content/uploads/2009/09/23092009887th.jpg" alt="Intel SR1530HSH 1U Server - Rear" width="250" height="188" /><p class="wp-caption-text">Intel SR1530HSH 1U Server - Rear</p></div>
<div id="attachment_79" class="wp-caption alignleft" style="width: 260px"><img class="size-full wp-image-79" title="Intel SR1530HSH 1U Server - Top" src="http://blog.cyprix.com.au/wp-content/uploads/2009/09/23092009888th.jpg" alt="Intel SR1530HSH 1U Server - Top" width="250" height="188" /><p class="wp-caption-text">Intel SR1530HSH 1U Server - Top</p></div>
<div id="attachment_81" class="wp-caption alignleft" style="width: 260px"><img class="size-full wp-image-81" title="Intel SR1530HSH 1U Server - Inside" src="http://blog.cyprix.com.au/wp-content/uploads/2009/09/23092009889th.jpg" alt="Intel SR1530HSH 1U Server - Inside" width="250" height="188" /><p class="wp-caption-text">Intel SR1530HSH 1U Server - Inside</p></div>
]]></content:encoded>
			<wfw:commentRss>http://thatsamguy.com/2009/09/new-server-with-photos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating to nginx, php 5.3, mysql 5.1, mandriva 2010&#8230; and more</title>
		<link>http://thatsamguy.com/2009/09/migrating-to-nginx-php-5-3-mysql-5-1-mandriva-2010-and-more/</link>
		<comments>http://thatsamguy.com/2009/09/migrating-to-nginx-php-5-3-mysql-5-1-mandriva-2010-and-more/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 16:40:16 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mandriva]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.cyprix.com.au/?p=56</guid>
		<description><![CDATA[Lots going on at the moment. I&#8217;m migrating most of mine and my clients websites to nginx from apache in preparation for moving everything to a new server. First thoughts? Nginx is super fast, reasonably easy to configure (once you figure out the php issues) and saves a heap on memory. Downside? I&#8217;ve had the [...]]]></description>
			<content:encoded><![CDATA[<p>Lots going on at the moment. I&#8217;m migrating most of mine and my clients websites to <a href="http://wiki.nginx.org">nginx</a> from apache in preparation for moving everything to a new server.</p>
<p>First thoughts? Nginx is super fast, reasonably easy to configure (once you figure out the php issues) and saves a heap on memory. Downside? I&#8217;ve had the odd niggle with moving old sites across &#8211; especially since I&#8217;m moving to php 5.3 and MySQL 5.1 at the same time, otherwise all good.</p>
<p>The other major change is the look of this blog. The old K2 theme was becoming an issue to deal with (mainly because I didn&#8217;t update it enough) so I&#8217;ve now moved to this lovely theme: <a href="http://wordpress.org/extend/themes/inove">inove</a>. I&#8217;ve also done a fresh wordpress install of 2.8.4 and added pretty links &#8211; so anyone linking to the old structure might have the odd issue, but otherwise should be painless. Oh yeah &#8211; any images on the older posts (pre Aug 2009) are gone.</p>
<p>Anyway here is a list of upgrades currently underway:</p>
<ul>
<li>php 5.2.x to 5.3.0</li>
<li>mysql 5.0 to mysql-max 5.1</li>
<li>apache 2.2/mod_php to nginx 0.8.10/php-fcgi</li>
<li>athlon64 2ghz 1gb ram to athlon64 X2 2ghz 2gb ram</li>
<li>mandriva 2008.x/2009.x to 2010.0 (Cooker)</li>
<li>wordpress 2.x.x to 2.8.4</li>
<li>mediawiki 1.x to 1.15.1</li>
<li>bind 9 to powerdns 2.9.22</li>
<li>and a few more that i&#8217;ve forgotten about</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://thatsamguy.com/2009/09/migrating-to-nginx-php-5-3-mysql-5-1-mandriva-2010-and-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

