<?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>Randomness from RES &#187; Benchmarking</title>
	<atom:link href="http://www.robertswarthout.com/category/benchmarking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.robertswarthout.com</link>
	<description>Things that I run across that might be useful to others...</description>
	<lastBuildDate>Sun, 21 Feb 2010 01:56:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Continued: MySQL connection benchmarking</title>
		<link>http://www.robertswarthout.com/2008/08/continued-mysql-connection-benchmarking/</link>
		<comments>http://www.robertswarthout.com/2008/08/continued-mysql-connection-benchmarking/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 19:08:58 +0000</pubDate>
		<dc:creator>Robert Swarthout</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.robertswarthout.com/?p=62</guid>
		<description><![CDATA[I was asked by a fellow Schematicer to see if there was a performance difference if the fourth parameter of mysql_connect was set to true if it would make any difference. I would assume that it would not make any difference but I went ahead and ran the variation to be sure, the results are [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked by a fellow <a href="http://www.schematic.com">Schematic</a>er to see if there was a performance difference if the fourth parameter of <a href="http://www.php.net/mysql_connect">mysql_connect</a> was set to true if it would make any difference. I would assume that it would not make any difference but I went ahead and ran the variation to be sure, the results are below.</p>
<p>Run #1:</p>
<blockquote><p>11409 fetches, 20 max parallel, 45636 bytes, in 600.011 seconds<br />
4 mean bytes/connection<br />
19.0146 fetches/sec, 76.0586 bytes/sec<br />
msecs/connect: 0.211857 mean, 39.668 max, 0.029 min<br />
msecs/first-response: 1050.65 mean, 2662.53 max, 323.514 min<br />
HTTP response codes: code 200 &#8212; 11409</p></blockquote>
<p>Run #2:</p>
<blockquote><p>11141 fetches, 20 max parallel, 44564 bytes, in 600.005 seconds<br />
4 mean bytes/connection<br />
18.5682 fetches/sec, 74.2727 bytes/sec<br />
msecs/connect: 0.206869 mean, 30.293 max, 0 min<br />
msecs/first-response: 1076.17 mean, 2317.13 max, 350.16 min<br />
HTTP response codes: code 200 &#8212; 11141</p></blockquote>
<p>Run #3:</p>
<blockquote><p>11183 fetches, 20 max parallel, 44732 bytes, in 600 seconds<br />
4 mean bytes/connection<br />
18.6383 fetches/sec, 74.5533 bytes/sec<br />
msecs/connect: 0.201182 mean, 24.691 max, 0.03 min<br />
msecs/first-response: 1071.81 mean, 2448.18 max, 366.686 min<br />
HTTP response codes: code 200 &#8212; 11183</p></blockquote>
<p><strong>Results Analysis</strong></p>
<ul>
<li>Average requests per second: 18.7043</li>
<li>Average requests completed: 11,244</li>
</ul>
<p>These results can be compared to the <a href="/2008/08/benchmarking-of-mysql-persistent-connections-vs-non-persistent-connections/">previous post on this topic</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertswarthout.com/2008/08/continued-mysql-connection-benchmarking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Benchmarking of MySQL Persistent Connections vs Non-Persistent Connections</title>
		<link>http://www.robertswarthout.com/2008/08/benchmarking-of-mysql-persistent-connections-vs-non-persistent-connections/</link>
		<comments>http://www.robertswarthout.com/2008/08/benchmarking-of-mysql-persistent-connections-vs-non-persistent-connections/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 14:37:37 +0000</pubDate>
		<dc:creator>Robert Swarthout</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.robertswarthout.com/?p=28</guid>
		<description><![CDATA[This post will be about the what always seems to be a hot topic among PHPers about what connection type to use when connection to a MySQL database.
I used MySQL 5.0.45, PHP 5.2.4 for this benchmarking. You can download the same sample MySQL database that is used for this set of benchmarking by visiting http://dev.mysql.com/doc/#sampledb. [...]]]></description>
			<content:encoded><![CDATA[<p>This post will be about the what always seems to be a hot topic among PHPers about what connection type to use when connection to a MySQL database.</p>
<p>I used MySQL 5.0.45, PHP 5.2.4 for this benchmarking. You can download the same sample MySQL database that is used for this set of benchmarking by visiting <a href="http://dev.mysql.com/doc/#sampledb">http://dev.mysql.com/doc/#sampledb</a>. In the list of example databases, choose the one named &#8217;sakila&#8217;.</p>
<p>For each connection type I will run three tests to see compensate for variations in tests. I will be using <a href="http://www.acme.com/software/http_load/">http_load</a> to do the benchmarking of the connection file. To view each of the connection files, download the file bundle at the end of this post.</p>
<p>Below is the benchmark command with the options used for each run.</p>
<blockquote><p>./http_load -verbose -parallel 20 -seconds 600 urls.txt</p></blockquote>
<p>The urls.txt file contains the following:</p>
<blockquote><p>http://127.0.0.1/mysql_connection_bench_{CONNECT_TYPE}.php</p></blockquote>
<p>Between each benchmark run I will restart both Apache and MySQL.</p>
<p><strong>Results for the standard MySQL functions in PHP using mysql_connect.</strong></p>
<p>Run #1:</p>
<blockquote><p>11024 fetches, 20 max parallel, 44096 bytes, in 600.007 seconds<br />
4 mean bytes/connection<br />
18.3731 fetches/sec, 73.4925 bytes/sec<br />
msecs/connect: 0.22087 mean, 48.992 max, 0.03 min<br />
msecs/first-response: 1087.74 mean, 2880.95 max, 355.012 min<br />
HTTP response codes: code 200 &#8212; 11024</p></blockquote>
<p>Run #2:</p>
<blockquote><p>10895 fetches, 20 max parallel, 43580 bytes, in 600.004 seconds<br />
4 mean bytes/connection<br />
18.1582 fetches/sec, 72.6328 bytes/sec<br />
msecs/connect: 0.219867 mean, 48.58 max, 0.031 min<br />
msecs/first-response: 1100.1 mean, 2623.47 max, 369.341 min<br />
HTTP response codes: code 200 &#8212; 10895</p></blockquote>
<p>Run #3:</p>
<blockquote><p>11134 fetches, 20 max parallel, 44536 bytes, in 600.003 seconds<br />
4 mean bytes/connection<br />
18.5566 fetches/sec, 74.2264 bytes/sec<br />
msecs/connect: 0.217796 mean, 42.036 max, 0.03 min<br />
msecs/first-response: 1076.59 mean, 3079.73 max, 270.734 min<br />
HTTP response codes: code 200 &#8212; 11134</p></blockquote>
<p><strong>Results for the standard MySQL functions in PHP using mysql_pconnect.</strong></p>
<p>Run #1:</p>
<blockquote><p>10982 fetches, 20 max parallel, 43928 bytes, in 600.025 seconds<br />
4 mean bytes/connection<br />
18.3026 fetches/sec, 73.2103 bytes/sec<br />
msecs/connect: 0.216663 mean, 69.795 max, 0 min<br />
msecs/first-response: 1091.52 mean, 3166.82 max, 254.36 min<br />
HTTP response codes: code 200 &#8212; 10982</p></blockquote>
<p>Run #2:</p>
<blockquote><p>11002 fetches, 20 max parallel, 44008 bytes, in 600.001 seconds<br />
4 mean bytes/connection<br />
18.3366 fetches/sec, 73.3465 bytes/sec<br />
msecs/connect: 0.20555 mean, 47.176 max, 0.031 min<br />
msecs/first-response: 1089.51 mean, 2953.82 max, 414.826 min<br />
HTTP response codes: code 200 &#8212; 11002</p></blockquote>
<p>Run #3:</p>
<blockquote><p>11196 fetches, 20 max parallel, 44784 bytes, in 600 seconds<br />
4 mean bytes/connection<br />
18.66 fetches/sec, 74.6399 bytes/sec<br />
msecs/connect: 0.2013 mean, 22.478 max, 0.03 min<br />
msecs/first-response: 1070.5 mean, 2506.02 max, 448.161 min<br />
HTTP response codes: code 200 &#8212; 11196</p></blockquote>
<p><strong>Results for non-persistent connections with PDO_MYSQL.</strong></p>
<p>Run #1:</p>
<blockquote><p>10995 fetches, 20 max parallel, 43980 bytes, in 600.008 seconds<br />
4 mean bytes/connection<br />
18.3248 fetches/sec, 73.299 bytes/sec<br />
msecs/connect: 0.203731 mean, 17.309 max, 0.029 min<br />
msecs/first-response: 1090.44 mean, 2852.34 max, 358.45 min<br />
HTTP response codes: code 200 &#8212; 10995</p></blockquote>
<p>Run #2:</p>
<blockquote><p>10971 fetches, 20 max parallel, 43884 bytes, in 600.002 seconds<br />
4 mean bytes/connection<br />
18.285 fetches/sec, 73.1398 bytes/sec<br />
msecs/connect: 0.21357 mean, 32.036 max, 0 min<br />
msecs/first-response: 1092.36 mean, 3515.71 max, 456.688 min<br />
HTTP response codes: code 200 &#8212; 10971</p></blockquote>
<p>Run #3:</p>
<blockquote><p>11161 fetches, 20 max parallel, 44644 bytes, in 600.001 seconds<br />
4 mean bytes/connection<br />
18.6016 fetches/sec, 74.4065 bytes/sec<br />
msecs/connect: 0.20571 mean, 31.679 max, 0.031 min<br />
msecs/first-response: 1073.96 mean, 2539.06 max, 351.236 min<br />
HTTP response codes: code 200 &#8212; 11161</p></blockquote>
<p><strong>Results for persistent connections with PDO_MYSQL.</strong></p>
<p>Run #1:</p>
<blockquote><p>10347 fetches, 20 max parallel, 41388 bytes, in 600.006 seconds<br />
4 mean bytes/connection<br />
17.2448 fetches/sec, 68.9793 bytes/sec<br />
msecs/connect: 0.253049 mean, 96.354 max, 0 min<br />
msecs/first-response: 1158.52 mean, 2596.78 max, 282.647 min<br />
HTTP response codes: code 200 &#8212; 10347</p></blockquote>
<p>Run #2:</p>
<blockquote><p>11106 fetches, 20 max parallel, 44424 bytes, in 600.008 seconds<br />
4 mean bytes/connection<br />
18.5098 fetches/sec, 74.0391 bytes/sec<br />
msecs/connect: 0.226898 mean, 51.29 max, 0.03 min<br />
msecs/first-response: 1079.29 mean, 2393.4 max, 311.85 min<br />
HTTP response codes: code 200 &#8212; 11106</p></blockquote>
<p>Run #3:</p>
<blockquote><p>10978 fetches, 20 max parallel, 43912 bytes, in 600.029 seconds<br />
4 mean bytes/connection<br />
18.2958 fetches/sec, 73.1831 bytes/sec<br />
msecs/connect: 0.210895 mean, 30.339 max, 0 min<br />
msecs/first-response: 1091.98 mean, 3455.6 max, 373.751 min<br />
HTTP response codes: code 200 &#8212; 10978</p></blockquote>
<p><strong>Results Analysis</strong></p>
<ul>
<li>mysql_connect
<ul>
<li>Average requests per second: 18.3626</li>
<li>Average requests completed: 11,017</li>
</ul>
</li>
<li>mysql_pconnect
<ul>
<li>Average requests per second: 18.4330</li>
<li>Average requests completed: 11,060</li>
</ul>
</li>
<li>PDO_MySQL non-persistent
<ul>
<li>Average requests per second: 18.4038</li>
<li>Average requests completed: 11,042</li>
</ul>
</li>
<li>PDO_MySQL persistent
<ul>
<li>Average requests per second: 18.0168</li>
<li>Average requests completed: 10,810</li>
</ul>
</li>
</ul>
<p>Basically what the numbers above shows us is that in an isolated environment it makes no difference which connection type you are going to use. My past experience in live heavily trafficked environment says that using non-persistent connections is better than using persistent connections. Where this difference comes shows itself the most is when an apache thread will hang and still hold the persistent connection to mysql preventing other apache processes from connecting. By tweaking your apache and mysql settings you can achieve very good performance with non-persistent connections.</p>
<p><a href="/wp-content/uploads/benchmarking_source.tar.gz">Source files</a> for this benchmarking test.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertswarthout.com/2008/08/benchmarking-of-mysql-persistent-connections-vs-non-persistent-connections/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
