Page 1 of 1
Are there thread pools in PHP?
Posted: Tue Nov 21, 2006 7:37 pm
by ivj
I'm learning PHP and reading PHP-MySQL tutorials I notice that you make a new connection to the database every time.
Coming from Java that sounds terribly inefficient. In 99% of DB applications I'd have a thread pool constantly running a few idle connections. Doesn't PHP do that sort of thing somehow? Googling didn't help much, so what do you pros say?
Posted: Tue Nov 21, 2006 7:49 pm
by RobertGonzalez
I don't think so. I am looking into connection pooling tools right now for an app I am working on.
Posted: Tue Nov 21, 2006 9:01 pm
by wyrmmage
Not that I have heard of, however there is such a thing as a "persistent connection", but it's not used much.
-wyrmmage
Re: Are there thread pools in PHP?
Posted: Wed Nov 22, 2006 4:26 am
by onion2k
ivj wrote:I'm learning PHP and reading PHP-MySQL tutorials I notice that you make a new connection to the database every time.
Coming from Java that sounds terribly inefficient. In 99% of DB applications I'd have a thread pool constantly running a few idle connections. Doesn't PHP do that sort of thing somehow? Googling didn't help much, so what do you pros say?
mysql_pconnect() will check for a pooled (persistant) connection that will be reused if there's one free, or creates a new one if there isn't a spare. You need to be careful when you're using them because you can easily sink MySQL. Read this:
http://uk2.php.net/manual/en/features.p ... ctions.php
Posted: Wed Nov 22, 2006 10:25 am
by RobertGonzalez
So far in my quest for a connection pooler, I have found one that seems like it might help. It does have its issues, but it also handles pooling. It is
SQL Relay.