Home Projects Jobs Clientele Contact


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Db pool [was: My little comments to CPP code]

sergey@total-knowledge.com wrote:
> - What pooling strategies we want to support (and why)
> 1. Close connections that have not been used for a specified time.
> 2. Queueing connections. If there is max connections for the pool
> specified, then objects requesting a connection can be put on hold until
> another object frees its connection.
How about fixed number of connections open at creation time?
For example, make it as large as CPPSERV's thread pool? This
way we'll always have a connection ready when a request arrives.
> - How will pooling and HTTP request object lifetimes will interoperate
> Pool initialized at init() time(not sure about this one), then the same
> connection can be used for subsequent requests. Since servlets can keep
> information between requests, a pool lives longer then HTTP request.
And what happens to connection during request processing?
> - What will API look like
> 1. The uuDBPool() constructor that takes these parameters:
> string login,
> string password,
Whose login and password?
> int server(this one is needed for login() proc),
> string sessionid(needed for login() proc, not really used now),
How does that correlate with initializing the pool at servlet init time?
> int maxCon(max connections for this pool).

> - Provide few use cases relevant for our application
> 1. Browser sends request to the servlet.
> 2. No connections available in the pool.
> 3. Is maxCon been reached?
> 	a. Case "NO"
> 		1) Create new connection using getConnection()' login() procedure.
> 		2) Increament connections counter in the pool.
> 		3) Return connection to the client.
> 	b. Case "YES"
> 		1) Wait 'timeout' milliseconds.
UGH. No. Read up on mutexes and signals. Also check out ThreadPool
in cppserv.
> 		2) Return to 3.
> Another case:
> 1. Browser sends request to the servlet.
> 2. Connections available in the pool.
> 3. Return a connection using getConnection()
> One more:
> 1. User leaves the site.
How do we know that?
> 2. Connection returned to the pool using releaseConnection() function
Why did we have a connection?
> 3. Number of used connections is decremented.
> I'm not sure when shutdown() should be called.
Why did you introduce it then?

Ilya A. Volynets-Evenbakh
Total Knowledge. CTO

Authoright © Total Knowledge: 2001-2008