<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: PHP And pg_connect: Post Mortem</title>
	<link>http://blog.charcoalphile.com/2008/02/24/php-and-pg_connect-post-mortem/</link>
	<description>On Databases, Recovery, Tech</description>
	<pubDate>Thu, 09 Sep 2010 08:23:31 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: admin</title>
		<link>http://blog.charcoalphile.com/2008/02/24/php-and-pg_connect-post-mortem/#comment-167</link>
		<author>admin</author>
		<pubDate>Mon, 10 Mar 2008 21:38:52 +0000</pubDate>
		<guid>http://blog.charcoalphile.com/2008/02/24/php-and-pg_connect-post-mortem/#comment-167</guid>
		<description>Yeah, connecting through /var/lib/postgresql has half the overhead of 127.0.0.1, but you would either have to setup an ident user or reconfigure pg_hba.conf.

I'm starting to think the reason Python was so much faster is because PostgreSQL was running out of connections. After giving pgpool a hard limit of 90 to the maximum number of open connections, performance of the Python script dropped significantly, to ~300 requests a second (still faster than PHP). It may just be that my setup isn't up to par in order to test it, since there really shouldn't be too many open connections with a concurrency of ten. I'll have to give it a shot on a Core 2 Duo, when I get some time.

I know all about the evils of persistent connections. Even with a very small number of users, you can easily run out of connections. Since connections are kept open per-apache-process, and not pooled across all Apache processes like many believe, benchmarks should be taken with a grain of salt, as persistent connections work in favor of the benchmark.</description>
		<content:encoded><![CDATA[<p>Yeah, connecting through /var/lib/postgresql has half the overhead of 127.0.0.1, but you would either have to setup an ident user or reconfigure pg_hba.conf.</p>
<p>I&#8217;m starting to think the reason Python was so much faster is because PostgreSQL was running out of connections. After giving pgpool a hard limit of 90 to the maximum number of open connections, performance of the Python script dropped significantly, to ~300 requests a second (still faster than PHP). It may just be that my setup isn&#8217;t up to par in order to test it, since there really shouldn&#8217;t be too many open connections with a concurrency of ten. I&#8217;ll have to give it a shot on a Core 2 Duo, when I get some time.</p>
<p>I know all about the evils of persistent connections. Even with a very small number of users, you can easily run out of connections. Since connections are kept open per-apache-process, and not pooled across all Apache processes like many believe, benchmarks should be taken with a grain of salt, as persistent connections work in favor of the benchmark.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Eure</title>
		<link>http://blog.charcoalphile.com/2008/02/24/php-and-pg_connect-post-mortem/#comment-159</link>
		<author>Ian Eure</author>
		<pubDate>Fri, 07 Mar 2008 21:18:08 +0000</pubDate>
		<guid>http://blog.charcoalphile.com/2008/02/24/php-and-pg_connect-post-mortem/#comment-159</guid>
		<description>Persistent connections should be avoided at all costs. Because the connections are held open after they're not needed, the DB server ends up with a much larger number of connections, and (at least with MySQL) will start refusing them when it hits it's limit.

You might try experimenting with other authentication methods on the DB server to speed up the pg_connect() call. The PHP function is a very thin wrapper around the PostgreSQL library's pg_connect(), so there shouldn't be much difference between PHP and any other binding. Perhaps PyDB is lazy-connecting, or shuffling that latency in some other way?

I'd be interested to see how the PHP pg_connect() compares with C.

Oh, and if you're connecting to a name (db.foo.com) vs an IP, change. DNS lookups could be slowing things down. You could also try connecting via a socket instead of TCP/IP.</description>
		<content:encoded><![CDATA[<p>Persistent connections should be avoided at all costs. Because the connections are held open after they&#8217;re not needed, the DB server ends up with a much larger number of connections, and (at least with MySQL) will start refusing them when it hits it&#8217;s limit.</p>
<p>You might try experimenting with other authentication methods on the DB server to speed up the pg_connect() call. The PHP function is a very thin wrapper around the PostgreSQL library&#8217;s pg_connect(), so there shouldn&#8217;t be much difference between PHP and any other binding. Perhaps PyDB is lazy-connecting, or shuffling that latency in some other way?</p>
<p>I&#8217;d be interested to see how the PHP pg_connect() compares with C.</p>
<p>Oh, and if you&#8217;re connecting to a name (db.foo.com) vs an IP, change. DNS lookups could be slowing things down. You could also try connecting via a socket instead of TCP/IP.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
