You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jukka Ruohonen <jr...@iki.fi> on 2013/02/25 09:52:44 UTC

A pool question

Hello.

A question related to pools. Background: a big application in which it is
preferable to enforce different roles for different databases and tables. 
This implies that there are different user names and passwords for different
connections. As I understand, there are two options for connection pooling
in a scheme like this:

	A. Create different resources for the different roles, each having
	   the user names and passwords defined as constants in the Tomcat
	   configuration files.

	B. Group the different roles into a bigger scheme and use the option
	   'alternateUsernameAllowed' to obtain the connections with the
	    specific user names and passwords.

Both were tested to work. But I wonder:

	1. The first option seems intuitively more efficient. But on the
	   other hand, does each Resource define its own cleaner thread?
	   I wouldn't want to overburden the setup with too many threads.

	2. Are there any benchmarks on the option B? The plain FIFO seems
	   rather inefficient if there are many different users/passwords.

Any additional thoughts?

- Jukka.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: A pool question

Posted by Jukka Ruohonen <jr...@iki.fi>.
On Mon, Feb 25, 2013 at 09:33:28AM -0500, Daniel Mikusa wrote:
> Personally, what would worry me the most about this setup is configuring
> and tuning each of the pools.  Since they are all going to the same DB, I
> wouldn't want to overload the system with too many connection, but at the
> same time there has to be enough in each pool to service the needs of the
> application.  Plus getting this right, would seem to get trickier as you
> add more pools into the mix.

I concur. But on the other hand, this granularity offers clear benefits,
provided that one can identify the low rates and heavy hitters. The usual
concerns related to tuning apply of course, as you noted. We'll see.

On a related note, it seems that there is some also ambiguity in the
standars with respect to pooled getConnecton() vs. getConnection(user, pw).

Thanks for the comments,

Jukka.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: A pool question

Posted by Daniel Mikusa <dm...@vmware.com>.
On Feb 25, 2013, at 3:52 AM, Jukka Ruohonen wrote:

> Hello.
> 
> A question related to pools. Background: a big application in which it is
> preferable to enforce different roles for different databases and tables. 
> This implies that there are different user names and passwords for different
> connections. As I understand, there are two options for connection pooling
> in a scheme like this:
> 
> 	A. Create different resources for the different roles, each having
> 	   the user names and passwords defined as constants in the Tomcat
> 	   configuration files.

This would see to work best if you have a small and static number of user / password combinations.  How you define "small" is up to you though, and would partly depend on the resources available in your environment.

> 	B. Group the different roles into a bigger scheme and use the option
> 	   'alternateUsernameAllowed' to obtain the connections with the
> 	    specific user names and passwords.

This would seem to be a simpler approach if you have a large number of different logins or a dynamic number of possibilities.  For example, if each user that logs in has their own DB credentials.

> 
> Both were tested to work. But I wonder:
> 
> 	1. The first option seems intuitively more efficient. But on the
> 	   other hand, does each Resource define its own cleaner thread?
> 	   I wouldn't want to overburden the setup with too many threads.

Personally, what would worry me the most about this setup is configuring and tuning each of the pools.  Since they are all going to the same DB, I wouldn't want to overload the system with too many connection, but at the same time there has to be enough in each pool to service the needs of the application.  Plus getting this right, would seem to get trickier as you add more pools into the mix.

> 
> 	2. Are there any benchmarks on the option B? The plain FIFO seems
> 	   rather inefficient if there are many different users/passwords.

You might be better off rolling your own benchmarks here.  It'll take a little time, but you can see how it performs given your specific definitions of "many different users/passwords".

Dan


> 
> Any additional thoughts?
> 
> - Jukka.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: A pool question

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jukka,

On 2/28/13 4:25 PM, Christopher Schultz wrote:
> On 2/25/13 12:52 AM, Jukka Ruohonen wrote:
>> A question related to pools. Background: a big application in
>> which it is preferable to enforce different roles for different
>> databases and tables. This implies that there are different user
>> names and passwords for different connections. As I understand,
>> there are two options for connection pooling in a scheme like
>> this:
> 
>> A. Create different resources for the different roles, each
>> having the user names and passwords defined as constants in the
>> Tomcat configuration files.
> 
>> B. Group the different roles into a bigger scheme and use the 
>> option 'alternateUsernameAllowed' to obtain the connections with 
>> the specific user names and passwords.
> 
> C. I believe that tomcat-pool (*not* the stock one based upon
> commons DBCP) supports the DataSource.getConnection(username,
> password) call and might even be smart enough to search-through
> existing connections for one that matches those credentials.
> 
> This will allow you to have a single DataSource but still have 
> different credentials for your connection on-demand.

Sorry, I forgot to mention how this is different from (B): you can use
as many usernames and passwords as you'd like. The downside,
obviously, is that you might have a lot of turnover (i.e. thrashing)
in your connection pool. But if that's essentially what your
requirements are, there's nothing you can do to minimize that problem.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEv9+gACgkQ9CaO5/Lv0PCKEQCfYO5TkkXm6gQFgqjU2hP1hMWG
S7oAoIyIWufo46+ygL3wPbK7h9lNevhl
=L5XQ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: A pool question

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jukka,

On 2/25/13 12:52 AM, Jukka Ruohonen wrote:
> A question related to pools. Background: a big application in which
> it is preferable to enforce different roles for different databases
> and tables. This implies that there are different user names and
> passwords for different connections. As I understand, there are two
> options for connection pooling in a scheme like this:
> 
> A. Create different resources for the different roles, each having 
> the user names and passwords defined as constants in the Tomcat 
> configuration files.
> 
> B. Group the different roles into a bigger scheme and use the
> option 'alternateUsernameAllowed' to obtain the connections with
> the specific user names and passwords.

C. I believe that tomcat-pool (*not* the stock one based upon commons
DBCP) supports the DataSource.getConnection(username, password) call
and might even be smart enough to search-through existing connections
for one that matches those credentials.

This will allow you to have a single DataSource but still have
different credentials for your connection on-demand.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEv9WcACgkQ9CaO5/Lv0PC96wCfThPzq93bKI/zgh+EygvHbxnQ
wJUAn1o7h5KBvCNGc68xSdJGcl7sorXJ
=DVTs
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org