tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: DBCP is Single Threaded
Date Thu, 07 Nov 2013 16:03:59 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Yogesh,

On 11/7/13, 10:58 AM, yogesh hingmire wrote:
> While looking to upgrade to tomcat7, i understand the connection
> pool is a major improvement. I read that
> 
> commons-dbcp is single threaded, in order to be thread safe
> commons-dbcp locks the entire pool, even during query validation.
> 
> So as i understand, the connection pool will be locked when handing
> out new connections and other threads which need connections from
> the pool will wait until they are handed their respective
> connection?
> 
> Is my understanding right and if anyone could explain this better

That is correct. This is because the checkout method is implemented
like this (ignore syntax issues, this is psuedocode, won't match
method signatures, etc.):

public synchronized Connection checkout()
{
   // obtain connection by whatever means necessary,
   // validate the connection, etc.
}

There's nothing particularly awkward, stupid or evil about the above
code. It's just that it uses "synchronized" for the whole method and
there are some performance penalties for doing that.

The term "single-threaded" is a bit misleading... of course DBCP is
thread-safe and multiple threads can access it, but there is
serialized access to the checkout method.

Tomcat-pool uses a different strategy for thread-safety that lends
itself to better performance under heavier loads.

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

iQIcBAEBCAAGBQJSe7nvAAoJEBzwKT+lPKRYgg4P/iC9QSrDoeNxpleTp5Rli1H0
fMQF2jW6BfVn82ITbViaXBMW54r8Xci2h4+DjNEOicw7TSEGxXU9UPuCzfTIlGwL
JDBObNBFSOaeMVK4NwcIAVz0ZKzRErCieXgOueJBUCOUqZEOOTcf4MzMS21EK97A
FAxhiwmcuRoSSMXZY55fTaE5bkPCSrZgkSPSwcz42FHu2gzbGPKzo+OKkSagZrUK
Or+fwKDiMXmZyWmpyCG/fyDVIQv3KAuYDA6TPqYXIf6vB3z64HjTvTcU5kvRw8A5
IlBgnp4lI62LG2ofC6GdRT188hQz2RTxg3P4Mg3EyVuWgUY5Ndozxtb+UJs7fafV
9xHnnK64eRTfN7aKS3On6znu+RCXFXs5UMPvzNtR6GJl5moIUMjA6kII3IbTYAx+
EE3MVLm/sr5SwVuZEH2x0f45lu5QFeFch8IdlwIE6YMNZkZtZ+79SOhDsMr8ZbE2
M6/jDhAoQiiOH+asOLdf+7IUf85qrYUXm9Dd3DrZ9y+GSJLux+QOQVq8onBnQlA4
eW6AeZO9yb4qhRvkqUr5idDE77HNpwb8gtBsFlbHor8pSVbGIJQYSvYGraxSSy3/
UmmjKGkewTz/AcTMq85Czt1QpbESsWT86jwEsRIxAxxkRBFuP1TCSo1PUelkzW3i
pm6PUNE4bsEXblYQ5aOT
=7qzz
-----END PGP SIGNATURE-----

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


Mime
View raw message