<?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>The Developer Day &#187; performance</title>
	<atom:link href="http://www.thedeveloperday.com/tag/performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedeveloperday.com</link>
	<description>Staying Curious</description>
	<lastBuildDate>Fri, 03 Feb 2012 12:03:22 +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>Optimizing MySQL on Ubuntu 10.10 Maverick</title>
		<link>http://www.thedeveloperday.com/optimizing-mysql-on-ubuntu-10-10-maverick/</link>
		<comments>http://www.thedeveloperday.com/optimizing-mysql-on-ubuntu-10-10-maverick/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 02:06:37 +0000</pubDate>
		<dc:creator>Žilvinas Šaltys</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[innodb]]></category>
		<category><![CDATA[MyISAM]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Tuning]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.thedeveloperday.com/?p=722</guid>
		<description><![CDATA[Since Ubuntu 9.04 Jaunty Jackalope Ubuntu ships with EXT4 as the default file system. Surprisingly it makes MySQL writes extremely slow. This post is targeted to developers who work on Linux using MySQL and who would like to optimize MySQL performance. Disk Performance Tuning First start by tuning your disk performance. To do that you&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>Since <strong>Ubuntu 9.04 Jaunty Jackalope</strong> Ubuntu ships with EXT4 as the default file system. Surprisingly it makes <strong>MySQL</strong> writes extremely slow. This post is targeted to developers who work on <strong>Linux</strong> using MySQL and who would like to optimize MySQL performance.</p>
<h2>Disk Performance Tuning</h2>
<p>First start by tuning your <strong>disk performance</strong>. To do that you&#8217;ll have to sacrifice <strong>data consistency</strong> over data write speed. First start by enabling <strong>journal_data_writeback</strong> on your partition. This will allow to write to disk before updating the EXT4 journal. If your box crashes before updating the journal you might loose new data or some deleted data might reappear.</p>
<blockquote style="background: #444; color: #fff; padding-left: 2px;"><p>
sudo tune2fs -o journal_data_writeback /dev/sda1 (use the right partition)
</p></blockquote>
<p>Next step is editing your <strong>/etc/fstab</strong> to change ext4 mounting options. My fstab file looks something like this:</p>
<blockquote style="background: #444; color: #fff; padding-left: 2px;"><p>
UUID=irrelevant / ext4 errors=remount-ro,noatime,nodiratime,data=writeback,barrier=0,nobh,commit=100,nouser_xattr 0 1
</p></blockquote>
<p>There&#8217;s a few non default options added to improve write performance over consistency. Journal data writeback is enabled by <strong>data=writeback</strong>. The main option which is slowing down MySQL is <strong>barrier=0</strong>. You could actually change this single option and MySQL write performance would increase dramatically. Disabling this option makes your <strong>new</strong> data less safe when a system crash happens. Option <strong>nobh</strong> tries to avoid associating buffer heads and offers a minor performance improvement. Another option <strong>commit=100</strong> says that all your updates are written to disk every 100 seconds. The default is 5 seconds. If your machine crashes you&#8217;re likely to loose 100 seconds of updates. Large commit values like 100 provide big performance improvements. And the last option <strong>nouser_xattr</strong> disables extended options on your filesystem and provides a minor <strong>performance boost</strong>.</p>
<p>Double check your /etc/fstab syntax and reboot.</p>
<h2>Tuning MySQL configuration</h2>
<p>MySQL configuration settings depend on what database engines you&#8217;re using. The most common ones are <strong>MyISAM</strong> and <strong>InnoDB</strong>. I will assume that you use both.</p>
<p><strong>Warning!</strong> Some of the configuration changes will or might make your database inaccessible. Therefore backup all your databases by dumping them to SQL to a safe location. Make sure to include triggers and stored procedures. Double check that you will be able to reimport your backups and only then proceed further. Some options will make your InnoDB database stop working. I&#8217;ll mark those. Also backup your MySQL configuration. Just in case.</p>
<p>MySQL settings depend on how much memory you have. I will assume a normal working station will have 4GB of RAM. Open your MySQL configuration file which on Ubuntu is located at /etc/mysql/my.cnf and set the following options.</p>
<p><em>transaction-isolation = READ-COMMITTED</em></p>
<p>As a developer you will probably not have transactions running in parallel. If you don&#8217;t care about transactions and still use InnoDB set the isolation level to READ-COMMITED. This will make your transactions only see committed data but won&#8217;t prevent phantom rows. Setting it to READ-COMMITED will also improve performance.</p>
<p><em>key_buffer = 512M</em></p>
<p>By far the most important option for MyISAM. MyISAM indexes are cached using in the key buffer. It&#8217;s usually a good bet to set it from 25% to 40% of memory available. As a developer you might not need that much but do not leave it at a default.</p>
<p><em>query_cache_size  = 256M</em></p>
<p>Caches query results. Especially useful if your applications don&#8217;t have caching.</p>
<p><em>innodb_buffer_pool_size = 1024M</em> (<strong>requires a backup and an import</strong>)</p>
<p>InnoDB buffer pool size is the most important option for InnoDB. If your whole database is InnoDB you can try and fit your whole database in memory. If you don&#8217;t have that much memory you can generally set 70% &#8211; 80% of memory available. On a development box you will probably want to have extra RAM for things like Gnome or your IDE.</p>
<p><em>innodb_additional_mem_pool_size = 32M</em><br />
<em>innodb_log_buffer_size = 4M</em><br />
<em>innodb_log_file_size = 128M</em></p>
<p><em>innodb_flush_log_at_trx_commit	= 2</em></p>
<p>This option tells InnoDB to only flush log data every two seconds. On development machines you can set this even higher because the only risk is losing transactions during a system crash. If your development machine crashes you probably won&#8217;t care about lost transactions. Experiment!</p>
<p><em>innodb_flush_method	= O_DIRECT</em></p>
<p>This options tells InnoDB to skip filesystem cache and write straight to disk since InnoDB already has it&#8217;s own cache &#8211; the buffer pool. You save yourself some RAM.</p>
<p><em>table_cache  = 1024</em></p>
<p>Caches open tables. Might not be very useful on a single dev box but useful in general on any database server.</p>
<p><em>myisam_use_mmap = 1</em></p>
<p><a href="http://www.mysqlperformanceblog.com/2006/05/26/myisam-mmap-feature-51/">Mmap is a new MyISAM feature</a> available with MySQL 5.1. Should improve MyISAM write/read performance ~6%.</p>
<p>To sum up all the settings on a 4GB work environment:</p>
<blockquote style="background: #444; color: #fff; padding-left: 2px;"><p>
<em>transaction-isolation = READ-COMMITTED</em><br />
<em>key_buffer = 512M</em><br />
<em>query_cache_size  = 256M</em><br />
<em>innodb_buffer_pool_size = 1024M</em><br />
<em>innodb_additional_mem_pool_size = 32M</em><br />
<em>innodb_log_buffer_size = 4M</em><br />
<em>innodb_log_file_size = 128M</em><br />
<em>innodb_flush_log_at_trx_commit	= 2</em><br />
<em>innodb_flush_method	= O_DIRECT</em><br />
<em>table_cache  = 1024</em><br />
<em>myisam_use_mmap = 1</em>
</p></blockquote>
<h2>Buy an SSD disk</h2>
<p>This is by far the best upgrade you can do. <strong>SSD</strong> does not have any moving mechanical parts therefore doing a random read or write is as fast as doing a sequential read or write. My work laptop <strong>Lenovo T400</strong> can push 3.5 MB with <strong>random writes</strong>, 35 MB with <strong>sequential writes</strong>, 2.6MB with <strong>random reads</strong> and 38MB with <strong>sequential reads</strong> per second. The same test with an SSD disk can push 220MB <strong>random writes</strong> and 330MB <strong>random reads</strong> with similar numbers for sequential reads and writes. So for IO access you can expect 10 &#8211; 100 times performance difference.</p>
<h2>Summary</h2>
<p>It&#8217;s easy to squeeze some extra performance out of your development environment by sacrificing data safety. In my case these changes made our database integration test suites run a lot quicker. So far I haven&#8217;t experienced any downsides from the above settings though you have to accept that one day it most likely will. Most of the database settings I&#8217;ve mentioned are those considered most when tuning production database servers. My final advice is take everything you read here with a pinch of salt as I am by far not an expert in these matters and everything listed here is gathered from various resources online.</p>
<h2>Resources</h2>
<p><a href="http://www.mysqlperformanceblog.com/2007/11/01/innodb-performance-optimization-basics/">InnoDB performance optimization basics</a><br />
<a href="http://www.mysqlperformanceblog.com/2006/09/29/what-to-tune-in-mysql-server-after-installation/">Tunning MySQL server after installation</a><br />
<a href="http://www.mysqlperformanceblog.com/2006/05/26/myisam-mmap-feature-51/">MyISAM MMAP feature</a><br />
<a href="http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html">MySQL transaction isolation levels</a><br />
<a href="http://www.mysqlperformanceblog.com/2010/02/28/why-you-should-ignore-mysqls-key-cache-hit-ratio/">Why you should ignore key cache hit ratio</a><br />
<a href="http://pclinuxos2007.blogspot.com/2009/06/tweaks-to-boot-ext4-filesystem.html">Tweaks to boost EXT4 performance</a><br />
|<a href="http://www.tomshardware.com/reviews/samsung-470-sandforce-best-ssd,2783-14.html">SSD Benchmarks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedeveloperday.com/optimizing-mysql-on-ubuntu-10-10-maverick/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PHP load testing tool</title>
		<link>http://www.thedeveloperday.com/php-load-testing-tool/</link>
		<comments>http://www.thedeveloperday.com/php-load-testing-tool/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 15:08:05 +0000</pubDate>
		<dc:creator>Žilvinas Šaltys</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[load-testing]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.thedeveloperday.com/php-load-testing-tool/</guid>
		<description><![CDATA[I needed to test load some of our applications. I&#8217;m currently using a windows machine as my workstation. For some weird reason I&#8217;ve decided to develop such a load testing tool myself. It was both interesting and fun. I used php curl extension multi_ functions that are only available since PHP5. The script is very [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to test load some of our applications. I&#8217;m currently using a windows machine as my workstation. For some weird reason I&#8217;ve decided to develop such a load testing tool myself. It was both interesting and fun.</p>
<p>I used php curl extension multi_ functions that are only available since PHP5. The script is very simple. It accepts an integer parameter with max clients and a string parameter where a URL list file resides. You can run the script either from the command line or a browser. The script outputs average client response time, average responses per minute, total amount of responses and time elapsed during test loading. After a client responds the tool requests another URL. You can only stop the tool by killing the process.</p>
<p>You can try my <a href="http://www.thedeveloperday.com/uploads/loader.rar" title="PHP load testing tool">php test loading tool</a> yourself. If you are looking for something more serious try apache <strong>ab</strong> under Linux or Cygwin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedeveloperday.com/php-load-testing-tool/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

