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?
Are there thread pools in PHP?
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Are there thread pools in PHP?
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.phpivj 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?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.