<?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>UNIXy &#187; MySQL</title>
	<atom:link href="http://blog.unixy.net/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.unixy.net</link>
	<description>Fully Managed Dedicated Servers</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:37:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Running mysql-proxy with cPanel remote mysql and proxy for localhost</title>
		<link>http://blog.unixy.net/2010/11/running-mysql-proxy-with-cpanel-remote-mysql-and-proxy-for-localhost/</link>
		<comments>http://blog.unixy.net/2010/11/running-mysql-proxy-with-cpanel-remote-mysql-and-proxy-for-localhost/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 21:47:41 +0000</pubDate>
		<dc:creator>UNIXy</dc:creator>
				<category><![CDATA[Challenge]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[localhost]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysql-proxy]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[remote mysql]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=800</guid>
		<description><![CDATA[Mysql-proxy is a neat tool that is badly needed to make remote MySQL server installations seem as if they were local (as in localhost). It is a convenience more than anything else. For example, if you are multi-tenant provider (a.k.a shared hosting provider), you would rather not ask your clients to set the db host to db.example.net [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F11%2Frunning-mysql-proxy-with-cpanel-remote-mysql-and-proxy-for-localhost%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F11%2Frunning-mysql-proxy-with-cpanel-remote-mysql-and-proxy-for-localhost%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div id="_mcePaste"><a title="MySQL Proxy" href="http://forge.mysql.com/wiki/MySQL_Proxy" target="_blank">Mysql-proxy</a> is a neat tool that is badly needed to make remote MySQL <a title="Server" href="http://www.unixy.net/dedicated-servers" target="_self">server</a> installations seem as if they were local (as in localhost). It is a convenience more than anything else. For example, if you are multi-tenant provider (a.k.a shared hosting provider), you would rather not ask your clients to set the db host to db.example.net instead of the widely used localhost. It becomes a maintenance challenge as you cluster more databases together with different web servers. By the way, the proposed workaround works well with cPanel too!</div>
<p></p>
<div>Before we get started, keep in mind that Mysql-proxy is much more capable than just making remote MySQL installations appear to be local. It can do caching, scripting, on-the-fly SQL manipulation, and much more.</div>
<p></p>
<div>Let&#8217;s get down to implementation! Once you get Mysql-proxy installed, you&#8217;ll need to set the init.d script so it runs on system startup. Luckily it already comes with a generic init.d script, which is good enough and only needs a slight change.</div>
<p>
Replace the PROXY_OPTIONS variable to the following:</p>
<blockquote><p><code>PROXY_OPTIONS="--daemon --admin-address=127.0.0.1:4402 --proxy-address=/var/lib/mysql/mysql.sock --proxy-backend-addresses=10.1.1.1:3306"</code></p></blockquote>
<p>10.1.1.1 being your remote MySQL node. Once that&#8217;s done, go ahead and restart mysql-proxy:</p>
<blockquote><p><code>/etc/init.d/mysql-proxy restart</code></p></blockquote>
<p>If all goes well, you should be able to grep the process:</p>
<blockquote><p><code>5 S root      5970     1  4  75   0 - 11330 -      Oct05 ?        03:20:35 /usr/local/sbin/mysql-proxy --daemon --admin-address=127.0.0.1:4402 --proxy-address=/var/lib/mysql/mysql.sock --proxy-backend-addresses=10.1.1.1:3306 --pid-file /var/run/mysql-proxy.pid<br />
</code></p></blockquote>
<p>Be sure to set php.ini to the following:</p>
<blockquote><p><code>mysql.allow_persistent = On<br />
mysql.max_persistent = -1<br />
mysql.protocol = "TCP"<br />
mysql.max_links = -1<br />
mysql.default_port = 3306<br />
mysql.default_socket =<br />
mysql.default_host =<br />
mysql.default_user =<br />
mysql.default_password =<br />
mysql.connect_timeout = 60<br />
mysql.trace_mode = Off<br />
</code></p></blockquote>
<p>That&#8217;s all folks! We hope you enjoyed this short article.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2010/11/running-mysql-proxy-with-cpanel-remote-mysql-and-proxy-for-localhost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[ERROR] /usr/sbin/mysqld: Out of memory (Needed bytes)</title>
		<link>http://blog.unixy.net/2010/03/error-usrsbinmysqld-out-of-memory-needed-bytes/</link>
		<comments>http://blog.unixy.net/2010/03/error-usrsbinmysqld-out-of-memory-needed-bytes/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 15:00:53 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Break-Fix]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysqld]]></category>
		<category><![CDATA[out of memory]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=275</guid>
		<description><![CDATA[Howdy! The above error can come up quite often on a busy database-driven website or it could happen at one time or the other for different reasons. Today, we are going to cover the main two reasons for it happening. I shall break this down by architecture. Linux x86_64 (64-bit) The Out of memory error [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F03%2Ferror-usrsbinmysqld-out-of-memory-needed-bytes%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F03%2Ferror-usrsbinmysqld-out-of-memory-needed-bytes%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Howdy!</p>
<p>The above error can come up quite often on a busy database-driven website or it could happen at one time or the other for different reasons. Today, we are going to cover the main two reasons for it happening. I shall break this down by architecture. </p>
<p><strong>
<li>Linux x86_64 (64-bit)</li>
<p></strong></p>
<p>The <em>Out of memory</em> error indicates that the whole system has run out of memory at that point in time. For example, I happened to be loading a customer&#8217;s database that required more than 4GB of free RAM on the system. The system had 2GB of free RAM to work with so the MySQL process failed to import the database due to a lack of memory. The solution here is to add more memory into the system.</p>
<p><strong>
<li>Linux i386 (32-bit)</li>
<p></strong></p>
<p>Here, the error indicates that either the system ran out of memory, just like in x86_64 above, or that the process cannot address more memory even if it is available. This is more peculiar to the architecture than it is a shortcoming of MySQL. 32-bit operating systems are not capable of letting a process address more than roughly 4GB of memory. The best approach here is to install a 64-bit OS that is capable of addressing that much RAM.</p>
<p>Keep in mind that UNIXy fully manages its customers&#8217; servers. Should this particular problem occur while assisting a customer, we are always more than happy to provide a complimentary memory upgrade to complete the task.</p>
<p>That&#8217;s all folks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2010/03/error-usrsbinmysqld-out-of-memory-needed-bytes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Note that the MySQL client library is not bundled anymore. Solved!</title>
		<link>http://blog.unixy.net/2010/01/note-that-the-mysql-client-library-is-not-bundled-anymore-solved/</link>
		<comments>http://blog.unixy.net/2010/01/note-that-the-mysql-client-library-is-not-bundled-anymore-solved/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 03:09:14 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Break-Fix]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[lib64]]></category>
		<category><![CDATA[lightspeed]]></category>
		<category><![CDATA[litespeed]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=232</guid>
		<description><![CDATA[This error is not specific to Litespeed but can be encountered while building PHP with MySQL support on 64-bit systems. The fix is to tell the build that the MySQL client is indeed installed, but in a different directory, by adding the following flag to the configure line in Litespeed: --with-libdir=lib64 The reason being the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F01%2Fnote-that-the-mysql-client-library-is-not-bundled-anymore-solved%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2010%2F01%2Fnote-that-the-mysql-client-library-is-not-bundled-anymore-solved%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This error is not specific to Litespeed but can be encountered while building PHP with MySQL support on 64-bit systems. The fix is to tell the build that the MySQL client is indeed installed, but in a different directory, by adding the following flag to the configure line in Litespeed:</p>
<blockquote><p><code>--with-libdir=lib64</code></p></blockquote>
<p>The reason being the build doesn&#8217;t know at this point that it is dealing with a 64-bit OS. If adding the above switch does not work, be sure to install the MySQL client and libraries.</p>
<p>That&#8217;s all folks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2010/01/note-that-the-mysql-client-library-is-not-bundled-anymore-solved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimize a Large High Traffic WordPress Blog</title>
		<link>http://blog.unixy.net/2009/12/optimize-a-large-high-traffic-wordpress-blog/</link>
		<comments>http://blog.unixy.net/2009/12/optimize-a-large-high-traffic-wordpress-blog/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 05:48:04 +0000</pubDate>
		<dc:creator>UNIXy</dc:creator>
				<category><![CDATA[Crash Course]]></category>
		<category><![CDATA[high traffic blog]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[optimize blog]]></category>
		<category><![CDATA[optimize SQL]]></category>
		<category><![CDATA[optimize wordpress]]></category>
		<category><![CDATA[speedup mysql]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress PHP optimization]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=146</guid>
		<description><![CDATA[In this post, we shall go through the steps required to optimize a WordPress blog. If you are a current customer of UNIXy (http://www.unixy.net), do know that we are happy to implement these changes for your blog free of charge. We are a fully managed provider so do take advantage of it. Contact us today! [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2009%2F12%2Foptimize-a-large-high-traffic-wordpress-blog%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2009%2F12%2Foptimize-a-large-high-traffic-wordpress-blog%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post, we shall go through the steps required to optimize a WordPress blog. If you are a current customer of UNIXy (<a href="http://www.unixy.net">http://www.unixy.net</a>), do know that we are happy to implement these changes for your blog free of charge. We are a fully managed provider so do take advantage of it. <a href="http://www.unixy.net/contact-unixy">Contact us</a> today!</p>
<p>There are times when hardware upgrades are not feasible due to either budgetary limits or time constraints. We understand that a WordPress blog could be hosted on a shared platform or dedicated server (VPS included) so we have written this post with that in mind. The first 5 steps can be completed in a shared environment where access to global configuration files is not permitted by the provider. All 11 steps can be completed on a dedicated server or Virtual Private Server (VPS).</p>
<ol>
<li> <strong>WP Supercache</strong></li>
</ol>
<p>WP Supercache is a WordPress plugin that once installed alleviates some of<strong> </strong>the burdens on the server. Essentially, it takes every visited PHP page, generates the HTML content, and stores it on disk for subsequent visits. This is called PHP caching. The performance gain is noticeable. Not only does it speed up requests and improves responsiveness but it also leads to less resource utilization on the server. To install WP Supercache, follow this link:</p>
<p style="text-align: center;"><a title="WP Supercache official page" href="http://ocaoimh.ie/wp-super-cache/" target="_blank">http://ocaoimh.ie/wp-super-cache/</a></p>
<p style="text-align: left; padding-left: 30px;"><strong>2. Turn Autosave Off</strong></p>
<p style="text-align: left;">The WP global variable <em>AUTOSAVE_INTERVAL </em>controls the how often WordPress auto saves posts as they are edited. For example, while editing or writing a new posts, WP could be automatically saving tens of copies of your posts to the main WordPress table. Each time such automatic save process kicks off the main posts table is locked in order to be updated, which prevents visitors from briefly accessing your blog. It also causes the load average to spike up. One could either increase the autosave interval or completely disable the functionality. To increase the interval to X number of seconds (the higher the better), do it as such inside the wp-config.php file:</p>
<blockquote>
<p style="text-align: left; padding-left: 30px;"><strong><code>define('AUTOSAVE_INTERVAL', 2200); // 2200 second autosave interval</code></strong></p>
</blockquote>
<p style="text-align: left;">To disable the autosave feature completely, create a simple plugin file and enable via wp-admin:</p>
<p><code><br />
</code></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><code></p>
<blockquote>
<p style="text-align: left; padding-left: 30px;"><strong>&lt;?php<br />
<code>/*<br />
Plugin Name: Disable Autosave<br />
*/<br />
function disable_autosave() {<br />
wp_deregister_script('autosave');<br />
}<br />
add_action( 'wp_print_scripts', 'disable_autosave' );</code><br />
?&gt;</strong></p>
</blockquote>
<p></code></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p style="text-align: left; padding-left: 30px;"><strong>3. Disable Revisioning</strong></p>
<p style="text-align: left;">This feature saves several revisions of the same post into the database. It clutters the posts table and ends up bloating indexes unecessarily. It&#8217;s best to disable this feature altogether if you don&#8217;t need it. Add this line to your wp-config.php to disable this feature:</p>
<blockquote>
<pre style="font-family: monospace; text-align: left;"><span style="color: #000000;"><strong><code>define('WP_POST_REVISIONS', <span style="font-weight: bold;">false</span>);</code></strong></span></pre>
</blockquote>
<p>No further action is needed.</p>
<p style="padding-left: 30px;"><strong>4. Disable Non-Cacheable SQL Plugins</strong></p>
<p>While it is a good idea to disable as many unneeded plugins as possible, it&#8217;s not always practical to do. But this step requires that you go through the code of each plugin and locate SQL queries that use the MySQL RAND() function. Because MySQL does not cache queries that use the random number generator function RAND(), there is a performance penalty associated with such plugins. For example, Random Post plugin uses RAND() in its select SQL, which forces the SQL to run against the database time and time again. You can locate the PHP scripts that use the RAND() function inside your plugin folder using this command:</p>
<blockquote><p><code>grep -i "rand()" -r wp-content/plugins</code></p></blockquote>
<p>Once located, one could either disable such plugin or replace MySQL RAND() with a PHP rand function. This way the PHP random function will be cached. The randomization will, however, not work as intended. The good news is that perceived functionality will not be much impacted.</p>
<p style="padding-left: 30px;"><strong>5. Convert MyISAM Tables to InnoDB</strong></p>
<p>The InnoDB engine is superior. There is no reason to run MyISAM anymore. Here is a Bash script that will convert all tables, that can be converted, to InnoDB. If you do not have access to a script shell, you can accomplish the same using phpMyAdmin or other MySQL management tools. Be sure to take a backup of the WordPress database before running this script. Also, be sure to define a maintenance window for this change as the alter locks up tables temporarily making the blog inaccessible:</p>
<blockquote><p><code>#!/bin/bash<br />
DBNAME="database";<br />
DBUSER="user";<br />
DBPASS="pass";</code></p>
<p><code><code>for t in $(mysql -u$DBUSER -p$DBPASS --batch --column-names=false -e "show tables" $DBNAME);<br />
do<br />
echo "Converting table $t";<br />
mysql -u$DBUSER -p$DBPASS -e "alter table ${t} type=InnoDB" $DBNAME;<br />
echo "Repair table $t";<br />
mysql -u$DBUSER -p$DBPASS -e "repair table ${t}" $DBNAME;<br />
done</code></code></p>
<p><code> </code></p></blockquote>
<p><code>Remember that those who are hosting their WordPress blog on a shared provider's server will not be able to proceed with the rest of the instructions. The following instructions require root-level access to the server and a technical understanding of systems.</code></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><code></p>
<p style="padding-left: 30px;"><strong>6. Increase Query Cache</strong></p>
<p>We have already covered MySQL's query cache thoroughly in a previous post. We will not cover this information here. Feel free to read our past post on our blog here:</p>
<p><a href="http://blog.unixy.net/2009/06/improve-performance-with-mysql-query-caching/">http://blog.unixy.net/2009/06/improve-performance-with-mysql-query-caching/</a></p>
<p><strong>7. Increase Sort Buffer Size</strong></p>
<p>The MySQL sort_buffer_size variable controls the amount of memory that MySQL can allocate to dedicated to sorting. In other words, the more SQL queries that need to sort data the larger this value needs to be. But it shouldn't be that large as it can affect performance negatively. For example, you wouldn't fill up a large container of water only to find out you can't carry it for a mile. Instead, it's best to fill the container with only enough water. The same idea applies to sort_buffer_size. It is usually best to set it to slightly than the amount of L2 CPU cache. So for a Xeon x3430 with 8MB cache that would be around 6MB. The final my.cnf entry would then be:</p>
<blockquote><p><strong>sort_buffer_size = 6M</strong></p></blockquote>
<p style="padding-left: 30px;"><strong>8. Increase Key Buffer Size</strong></p>
<p>This configuration settings controls the amount of memory that MySQL can use to fit index blocks into memory while manipulating indexes. Increasing this value as much as possible (within reason) can improve performance greatly. It prevents MySQL from having to use the disk as temporary storage for its work area. Edit the main my.cnf file and put the following entry.</p>
<blockquote><p><strong>key_buffer_size = 128M</strong></p></blockquote>
<p>Restart MySQL for changes to apply.</p>
<p style="padding-left: 30px;"><strong>9. Install and Configure Eaccelerator</strong></p>
<p>Eaccelerator is a PHP cache module that ensures minimal CPU processing. It essentially renders PHP scripts once and saves the HTML output for subsequent calls. The benefits are important. Checkout the Eaccelerator Wiki on how to compile, configure, and run it here:</p>
<p><a href="http://eaccelerator.net/wiki/InstallFromSource">http://eaccelerator.net/wiki/InstallFromSource</a></p>
<p style="padding-left: 30px;"><strong>10. Install Apache MPM Worker</strong></p>
<p>Apache's Worker can have advantages over its default MPM Prefork. It is somewhat lightweight in the sense that it's threading based and can thus smoothout load average spikes when traffic increases. Worker requires a rebuild of Apache. Luckily, someone has already covered the steps requires to rebuild Apache with this MPM. Check it out here:</p>
<p><a href="http://www.faqs.org/docs/Linux-HOWTO/Apache-Compile-HOWTO.html">http://www.faqs.org/docs/Linux-HOWTO/Apache-Compile-HOWTO.html</a></p>
<p>With this step we conclude our crash course / guide to optimizing and improving WordPress. If you are a customer and would like to implement any of these recommendations, don't hesitate to ping us. I hope you enjoyed this post.</p>
<p style="padding-left: 30px;"><strong>11. Install Varnish Cache</strong></p>
<p>Varnish Cache can be put in front of Apache and provides smart acceleration to your blog. We are so impressed with this open source accelerator that we create a <a title="Varnish Cache" href="http://www.unixy.net/varnish" target="_blank">Varnish cPanel</a> plugin for it. The results are amazing so highly recommend it.</p>
<p>That's all folks!</p>
<p><a href="http://blog.unixy.net/2009/06/improve-performance-with-mysql-query-caching/"></a></p>
<p></code></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2009/12/optimize-a-large-high-traffic-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Running vBulletin Cluster Using Varnish</title>
		<link>http://blog.unixy.net/2009/11/running-vbulletin-along-with-varnish/</link>
		<comments>http://blog.unixy.net/2009/11/running-vbulletin-along-with-varnish/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 15:38:30 +0000</pubDate>
		<dc:creator>UNIXy</dc:creator>
				<category><![CDATA[Crash Course]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[accelerator]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[failover]]></category>
		<category><![CDATA[litespeed]]></category>
		<category><![CDATA[load balance]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[varnish]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vBulletin]]></category>
		<category><![CDATA[VCL]]></category>
		<category><![CDATA[Xen]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=120</guid>
		<description><![CDATA[Update (2011-02-16): If you&#8217;re interested in running Varnish with cPanel, UNIXY has created a cPanel Varnish plugin. Our Varnish VCL configuration performs much better than Litespeed. Read more about it here: http://www.unixy.net/varnish Update (2010-10-09): Should you be interested in a managed vBulletin dedicated server know that UNIXy has built a system that is ideal for [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2009%2F11%2Frunning-vbulletin-along-with-varnish%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2009%2F11%2Frunning-vbulletin-along-with-varnish%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Update (2011-02-16):</strong> If you&#8217;re interested in running Varnish with cPanel, UNIXY has created a cPanel Varnish plugin. Our Varnish VCL configuration performs much better than Litespeed. Read more about it here: <a title="Varnish cPanel" href="http://www.unixy.net/varnish" target="_blank">http://www.unixy.net/varnish</a></p>
<p><strong>Update (2010-10-09): </strong>Should you be interested in a <a title="vBulletin managed server" href="http://www.unixy.net/">managed vBulletin dedicated server</a> know that UNIXy has built a system that is ideal for those that want to run a lightening fast vBulletin forum. Visit the following product link:</p>
<p style="text-align: center;"><strong> <a href="https://www.unixy.net/secure/cart.php?a=add&amp;pid=216">https://www.unixy.net/secure/cart.php?a=add&amp;pid=216</a></strong></p>
<p><a title="Varnish Cache" href="http://www.varnish-cache.info">Varnish</a> is an excellent Web accelerator that can be made to proxy requests in and out of a cluster of somewhat more fully fledged Web servers like Apache or Litespeed. It has some great features like its compiled language, called VCL, and C-like programming API.</p>
<p>Large vBulletin deployments tend to be heavy on CPU and memory due to PHP script processing. For a large vBulletin forum, we recommend a cluster of 5 physical servers with three of those running Xen virtualization. One of those servers will be dedicated to the MySQL master database. Three to be setup as &#8220;headless&#8221; PHP nodes and Varnish load balancing and failover. And finally one as the NFS file store. The three headless servers need to run Varnish in their own VM and Litespeed or Apache in their own VM similarly.</p>
<p>The varnish backend director functionality makes it ideal to balance incoming traffic across all PHP headless nodes. It makes the configuration scalable and plug and play especially when needing to scale out within hours. The challenge in this setup is in making Varnish work correctly with vBulletin. Otherwise, session problems will occur.</p>
<p>We have a lot to share on this implementation so keep checking this blog as we will post it all. In the next installment, we&#8217;ll go through our deployment of a large vBulletin forum for a customer. In the mean time, feel free to get in touch should you have a question or comment. If you are interested in us helping you accelerate your server, we have a page explaining the different technologies we deploy on our clients&#8217; dedicated servers. Read up here: <a href="http://www.unixy.net/accelerate-your-server/"><strong>http://www.unixy.net/accelerate-your-server</strong></a></p>
<p><strong>Update</strong>: we are offering a Varnish configuration for vBulletin (3 &amp; 4) for a one-time fee. We can also configure it free of charge should you decide to rent your fully managed dedicated server from UNIXY (http://www.unixy.net). Please <a href="http://www.unixy.net/contact-unixy">contact us</a> today to get your forum running with a blazing fast speed!</p>
<p>That&#8217;s all folks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2009/11/running-vbulletin-along-with-varnish/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improve Performance With MySQL Query Caching</title>
		<link>http://blog.unixy.net/2009/06/improve-performance-with-mysql-query-caching/</link>
		<comments>http://blog.unixy.net/2009/06/improve-performance-with-mysql-query-caching/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 05:38:00 +0000</pubDate>
		<dc:creator>UNIXy</dc:creator>
				<category><![CDATA[Crash Course]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[coalesce]]></category>
		<category><![CDATA[high CPU]]></category>
		<category><![CDATA[memory usage]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[performance improvement]]></category>
		<category><![CDATA[query cache]]></category>
		<category><![CDATA[query_cache_size]]></category>
		<category><![CDATA[speed up mysql]]></category>

		<guid isPermaLink="false">http://blog.unixy.net/?p=13</guid>
		<description><![CDATA[The MySQL query cache is used to store data retrieved using SELECT statements. The advantage of the query cache is that subsequent and identical SELECT statement results are retrieved directly from the query cache, which resides in memory. So instead of executing the SELECT statements again and again, the stream of data is pulled from [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.unixy.net%2F2009%2F06%2Fimprove-performance-with-mysql-query-caching%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.unixy.net%2F2009%2F06%2Fimprove-performance-with-mysql-query-caching%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The MySQL query cache is used to store data retrieved using SELECT statements. The advantage of the query cache is that subsequent and identical SELECT statement results are retrieved directly from the query cache, which resides in memory. So instead of executing the SELECT statements again and again, the stream of data is pulled from memory. The end result is lower CPU and disk hits, which can improve server load average and most importantly responsiveness.</p>
<p>The query cache functionality has enough smartness that once configured, it runs itself. MySQL will make sure to flush cached data if there&#8217;s an update that takes place. This ensures stale data is flushed out and replaced with fresh entries. There is, however, an extra step that is required. The cache tends to become fragmented over time. But nothing that cannot be addressed with a simple script (see below).</p>
<p>Stock MySQL configurations set the query cache to 32MB. This means that 32MB worth of server memory is pre-allocated to MySQL. If you have a relatively large database, you will most certainly gain from increasing that value. After configuring the query cache, it takes a while for MySQL to build the cache depending on how busy your MySQL server is.</p>
<p>Let&#8217;s get the query cache configured. Inside the <em>[mysqld]</em> section in the MySQL configuration file (ex: /etc/my.cnf), configure the options below. For a server with 8GB memory and a <em>very busy</em> database, set the cache to 1GB:</p>
<blockquote><p>[mysqld]</p>
<p>query_cache_size = 1024M</p></blockquote>
<p>Then restart MySQL for the new option to take effect. Run this command to verify that the new query cache value is in place and that the query cache feature is indeed enabled:</p>
<blockquote><p># mysql -u root -e &#8220;show variables like &#8216;%query%&#8217;&#8221;<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+<br />
| Variable_name                | Value      |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+<br />
| ft_query_expansion_limit     | 20         |<br />
<strong>| have_query_cache             | YES        |</strong><br />
| long_query_time              | 10         |<br />
| query_alloc_block_size       | 8192       |<br />
| query_cache_limit            | 1048576    |<br />
| query_cache_min_res_unit     | 4096       |<br />
<strong>| query_cache_size             | 1073741824 |</strong><br />
| query_cache_type             | ON         |<br />
| query_cache_wlock_invalidate | OFF        |<br />
| query_prealloc_size          | 8192       |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;+</p></blockquote>
<p>If the <strong>have_query_cache</strong> option is set to YES, it means that the query cache is indeed up and running. <strong>query_cache_size</strong> represents the cache size in bytes. You can also monitor the <em>mysqld</em> process using top and you will see its <em>RES</em> value increase over time to above 1gb. This would be a good sign asb MySQL fills up the query cache with result sets from SELECT. There is another way to check on cache usage and health. Run the following command:</p>
<blockquote><p># mysql -u root -e &#8220;show status like &#8216;qc%&#8217;&#8221;<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+<br />
| Variable_name           | Value     |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+<br />
<strong>| Qcache_free_blocks      | 69776     | </strong><br />
<strong> | Qcache_free_memory      | 756433256 |</strong><br />
| Qcache_hits             | 9518567   |<br />
| Qcache_inserts          | 3878394   |<br />
| Qcache_lowmem_prunes    | 49447     |<br />
| Qcache_not_cached       | 173233    |<br />
| Qcache_queries_in_cache | 122754    |<br />
| Qcache_total_blocks     | 315609    |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8211;+</p></blockquote>
<p>If <strong>Qcache_free_memory</strong> stays high over a few days means that the <em>query_cache_size</em> value is set too high. A high <strong>Qcache_free_blocks</strong> means that memory is fragmented. So it is time to coalesce (make memory blocks contiguous) the region. This is done with the following command:</p>
<blockquote><p># mysql -u root -p -e &#8220;flush query cache&#8221;</p></blockquote>
<p>Contrary to the command name, this does not flush the cache in the sense that all entries become invalid. It simply defragments the memory region that is assigned to the query cache. The above command should be put in a script that run every 6 hours or so. Create a root crontab entry as such:</p>
<blockquote><p>* 6/* * * * /root/coalesce.sh</p></blockquote>
<p>Where <em>coalesce.sh</em> is a shell script:</p>
<blockquote><p>#!/bin/bash</p>
<p>mysql -u root -pyour_root_password -e <code>"flush query cache"</code>;</p></blockquote>
<p>The query cache can be further configured to match your database&#8217;s usage pattern. Be sure to read the MySQL documentation for the details. Hopefully, this post will come in handy for those that have unused memory and need to make the most out of their server. As our customer, we configure the query cache  on your server from the get-go. Be sure to ask us how we can help with your online project!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unixy.net/2009/06/improve-performance-with-mysql-query-caching/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

