RE: [PHP4BETA] Database Connection Pooling
| From: | Peter Kocks | Date: | Wed, 01 Mar 2000 20:31:39 +0000 |
| Subject: | RE: [PHP4BETA] Database Connection Pooling | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-11288@lists.php.net to get a copy of this message | ||
>
> I don't see why you would think that a connection per process is better.
> Except for the case where EVERY hit requires a DB connection for handling
> of the request, you will always have extra, resource consuming
> connections.
> (Note that unless you have your MaxRequestsPerChild set very low, you
> will eventually have a db connection in every Apache child.)
Speaking from experience, I agree. I've seen a site with over 8,000
simultaneous database connections from 8,000 separate apache processes.
This is a really bad situation since most of those connections are idle, but
the database must cycle through each of those connections just to check to
see if there is a waiting request.
There are two alternatives. 1) forget about persistent connections all
together and just take the hit for opening and closing the connection.
Although this does not seem elegant I think in practice it is not nearly as
bad as people make it out to be. 2) Connection pooling all of the apache
processes into one database connection. This would be the best solution,
but also one that is not trivial to write correctly. A broken connection
pooler could end up causing more headaches than it is worth.
My 2 cents.
--pk