Connection Pool Showdown

I put C3P0, DBCP, and Proxool to the test and confirmed that DBCP is the fastest pool in the West, so long as there isn’t any complicated synchronization being done by the code using DBCP! C3P0, safe even with complicated synchronization and very, very configurable and robutst, came in a pretty close second. Proxool, the loser in this test, was surprisingly unable to deal with more threads requesting Connections than it’s maxSize. It wouldn’t block, it would instantly throw an Exception. SO, I made sure that the pool sizes for all 3 were larger than the number of threads which would be concurrently accessing the pools.

C3P0, DBCP, and Proxool battle it out

Connection Pool Showdown

JVM Version 1.6.0_05-ea
Windows XP[x86] – 2 processors
31.55MB/254.06MB Memory
Benchmark Threads Avg Nanos Slow Factor
DBCP 40 74092.28 1.00x
DBCP 30 75085.88 1.01x
DBCP 20 75230.27 1.02x
DBCP 10 76437.40 1.03x
C3P0 10 93405.98 1.26x
C3P0 30 94054.79 1.27x
C3P0 20 94087.60 1.27x
C3P0 40 94865.61 1.28x
DBCP 1 104907.12 1.42x
C3P0 1 116039.45 1.57x
Proxool 10 142769.39 1.93x
Proxool 20 143932.09 1.94x
Proxool 30 146066.93 1.97x
Proxool 40 148903.46 2.01x
Proxool 1 183513.91 2.48x

3 Responses to Connection Pool Showdown

  1. Can you explain what you mean by “complicated synchronization?” What in particular is it I need to watch out for and why?

  2. Well, I guess it doesn’t really have to be all that complicated to create an issue with DBCP. The thing is that DBCP’s methods for acquiring and returning connections to the pool are synchronized which make it possible for deadlocks to occur amongst client threads. With C3P0, this synchronization isn’t present ( on the returns, at least ) and therefore the deadlocks don’t happen. C3P0 has a separate pool of helper threads which are responsible for getting the threads back into the pool without synchronization.

  3. Nice work. A couple of questions.

    I’m confused by “…and confirmed that DBCP is the fastest pool in the West, so long as there isn’t any complicated synchronization being done by the code using DBCP!” You mean that DBCP is fastest if the code calling DBCP doesn’t use complicated synchronisation? If the code calling DBCP has performance problems, then of course DBCP can’t help. Wouldn’t the same be true for c3p0 and Proxool?

    Will you publish your test case for review?

    What version of each package did you use?

    thanks,
    matt