Despite the common assumption, PHP lacks an inherent connection pooling mechanism like that found in J2EE containers.
mysql_pconnect, often mistaken for connection pooling, is a persistent connection feature. While it maintains a persistent connection to the database, it differs from true connection pooling.
Connection pooling involves the management of connections by the application server. When a connection is needed, it is requested from the pool, with an available connection being allocated if one exists.
While connection pooling is unavailable in PHP, alternatives exist for scaling database connections. One such method is the singleton pattern.
To achieve similar functionality to connection pooling, the Oracle article (http://www.oracle.com/technetwork/articles/dsl/white-php-part1-355135.html) and the Apache documentation (http://www.apache2.es/2.2.2/mod/mod_dbd.html) provide insightful information on connection scaling.
Remember that Apache releases resources at the end of each request, limiting the effectiveness of mysql_pconnect. The singleton pattern or third-party solutions can supplement these techniques, but true connection pooling remains unavailable in PHP.
The above is the detailed content of Does PHP Really Lack Connection Pooling?. For more information, please follow other related articles on the PHP Chinese website!