commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Speirs <>
Subject Re: [dbcp] Handling many different user accounts over time
Date Thu, 08 Dec 2011 18:52:47 GMT
On Wed, Dec 7, 2011 at 11:27 AM, Cameron, Scott <> wrote:
> Hi,
> I'm considering using either SharedPoolDataSource or PerUserPoolDataSource to do some
connection pooling but I've noticed that there doesn't seem to be any way to configure an
upper bound on the total number of connections in the pool across all users.

What do you mean, "across all users"? Do you have different connection
strings (user/pass) for each person who connects to your database?

> For example, say I have 5,000 named users in my database.  Any of the 5,000 can come
in to request a DB connection at any time, but likely no more than, say, 100 of them will
ever be active at a particular point in time.  If I want to allow 3 connections per user,
how do I ensure that I'm not eventually going to end up with 15,000 open connection over time.
> It looks like the "maxTotal" setting on the GenericObjectPool (and GenericKeyedObjectPool)
can be used to control this such that when this absolute upper bound is reached on the pool
the least recently used 15% of connections will be recycled.  But neither SharedPoolDataSource
nor PerUserPoolDataSource expose any way to configure maxTotal.
> Is there another recommended way to solve this problem?  What do high-traffic web containers
like Tomcat or JBoss do to deal with this scenario (if they do deal with it)?

Do I understand correctly, if I show up to your site as user wspeirs,
then I'm connecting to your database as wspeirs? If so, then why
wouldn't you simply create a connection for that user and store it in
the user's session? When the session is destroyed, you close the
connection. There is a bit more "start-up" time in creating the
connection when they first show up, but it'll be live and active
during the rest of the time they are there.

That work for you?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message