Page 1 of 1

Is connection pooling worth the effort???

Posted: Fri Apr 07, 2006 7:55 am
by raghavan20
I was working on a rollback issue and finally found that the rollback did not work properly because another database wrapper was using a different dB connection and I had to pass the connection to get it work and I was thinking, is database connection pooling worth the effort and at a superficial point of view, eveybody knows that it can avoid lot of server connections but there are more hidden problems in it...

i came across an article and this has cautioned me before implementing connection pooling...
There are a couple of points that should be considered before using pooled connections. It is possible that if used incorrectly this can produce a security risk, or at least introduce problems. If your web server using PHP (for example) and pooled connections, does things to the connection, that leaves it it a different state at the end to how it started, you shouldn't use pooling. Lets take a example of this. Assume you have a page that requests a password from a user, then using this password, alters the default database to one that other users are not allowed access to, if this connection is reused by another user, they will have access to data they should not be allowed to see.
so I would request your views on the topic and suggest me the best ways to do pooling or if you are against pooling, please explain your opinions...

Posted: Sun Apr 09, 2006 10:14 pm
by Christopher
It sounds like your problem was not with connection pooling but instead with connection management. As for connection pooling (or persistent connections as they are called) in general I do the following:

1. I start with standard connections (creating a new connection each <db>_connect() call)

2. If I start running out of connection I tune the database and OS setting to try to solve the problem.

3. If there are still problems with connections and I see that connections are occuring in a way that pooling might help and #2 did not solve the problem, then I try pooling (an change the database/OS setting accordingly).

Posted: Tue Apr 11, 2006 1:55 am
by raghavan20
have you come across any good tutorials which talk about PHP and Mysql connection management???

anyway, thanks very much for your answers.

Posted: Tue Apr 11, 2006 2:09 am
by Christopher
I don't know if I have ever read any tutorials on managing your connections. You seemed to have found your problem, which you said was "because another database wrapper was using a different dB connection." It seems like using multiple database wrappers is probably the only reason why you would have that problem.