Connection pool mgmt
Posted by: Stuart Peacock
Date: October 13, 2004 12:09PM

I'm having a good deal of fun using this!

Thanks to those who put their effort into this!

I have created a skeleton service in Visual Studio(C#) which accepts socket
requests for data. Each request is sent to the internal thread queue(the built
in one) and gets handed it's own mySql connection from a pool.

This has all worked great except for releasing connections which have aged
in the pool beyond the "connection lifetime" setting. I feel this name is misleading,
but we'll get to that.

I believe I've identified a minor bug. In the DBConnectString class, the "connection
lifetime" setting is hashed as "connect lifetime". When the ConnectionString class
references this setting, it searches for the hash string of "connection lifetime". This
caused it to always return 0. -> I modified the ConnectionString class to search for
"connect lifetime" and life was good.

NOW. Pool ageing.

Ain't source code a wonderful thing. I was not happy with the current scheme of
eliminating connections upon their return to the pool just because they were X
seconds old. This made no sense to me. So. What I did was to slightly modify the
GetPooledConnection method of the mySqlPool class. After the search of the idle
pool for an available connection, I continued through the idle pool looking for pool
members which had not been accessed (i.e. sat idle) for more than X seconds. This
required me to reset the created date on a connection each time I used it(no big
deal). I of course took into account the total connection count so as not to fall below
the "min pool level"(something which the old method did not do).

My only real hole is that it takes a incoming request to trigger this trimming back of
idle pool members. But hey... it's a start.

I'm interested in opinions and any other ideas you might have in regard to pooling.
I'd also be more than happy to share my skeleton.



Options: ReplyQuote

Written By
Connection pool mgmt
October 13, 2004 12:09PM
October 14, 2004 07:31AM
October 14, 2004 08:06AM
October 14, 2004 08:41AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.