|
-
Jul 30th, 2009, 02:52 AM
#1
Thread Starter
Hyperactive Member
Connection Pool
Hello,
I like to know about the term 'Connection Pool'. Along with this please let me know the followings.
1. How to establish connection pool using PHP and MySQL ?
2. How to use it efficiently in OOPS programing ?
Hope to hear you soon.
Thanks & Regards.
-
Aug 1st, 2009, 04:59 AM
#2
Re: Connection Pool
From Wikipedia:
In software engineering, a connection pool is a cache of database connections maintained by the database so that the connections can be reused when the database receives future requests for data. Connection pools are used to enhance the performance of executing commands on a database. Opening and maintaining a database connection for each user, especially requests made to a dynamic database-driven website application, is costly and wastes resources. In connection pooling, after a connection is created, it is placed in the pool and it is used over again so that a new connection does not have to be established. If all the connections are being used, a new connection is made and is added to the pool. Connection pooling also cuts down on the amount of time a user must wait to establish a connection to the database.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Aug 3rd, 2009, 12:17 AM
#3
Re: Connection Pool
(1) You do not need to maintain your own connection pool. In fact, because PHP is request-based and not a stateful application in its own right, maintaining a pool of connections is impossible. The MySQL driver maintains its own pool of connections which you can use from PHP by calling the mysql_pconnect function (or its equivalent in a data access library).
(2) In the majority of cases the build-up/tear-down overhead of non-persistent connections is minimal to non-existent, and this is especially true of MySQL connections. In such cases I would argue that persistent connections introduce more pitfalls than performance benefits. You can read about these pitfalls on the manual page for the mysql_pconnect function: Most boil down to the fact that many SQL functions we rely on (variables, session variables, transactions, locks) are connection-specific, and since pooling, by nature, reuses connections, it is easy to be caught out by entering the state created by the last time the connection was used.
The simple (one connection per request) approach scales well enough for most situations.
Last edited by penagate; Aug 3rd, 2009 at 12:20 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|