I am using hibernate 3.2.2 in my application. For connection pooling, we are using c3p0 0.9.1.
I am using Generic DAO Pattern and Open Session in View pattern to do database operation.
We are working on new website of existing website. Right now, the no of visits is half million page visit in existing application. I am confused with the c3p0 configuration. At what benchmark, i decide the no of connection to be opened. max-connection, min-connection, idletime, timeout etc....
You first need to determine what the pool will do if a request comes in and there is no free connection to serve it. Does it throw an exception? Return null? Block until another connection is returned to the pool?
Once you know what will happen when the capacity is exceeded, think about how you could deal with this in the calling code, and in what situations it is acceptable for this to happen. At some point as the number of connections increases you're going to have to start refusing to serve some requests, but only you can decide what that point is. The actual point depends on a lot of factors, including such things as
And so on and so forth.
Hopefully from the above you should be able to come up with the number of requests you need to be able to process concurrently (and if there are different types of request, you may need to take this into concern too). Then it's just a matter of looking at how the incoming requests acquire and use connections, reasoning and profiling until you discover the number of connections in the pool that is required to sustain your target rate of connections.
Don't forget to account for things like non-request threads (e.g. worker pools) getting their own connections from the same pool (pool needs to be bigger), as well as requests only holding a connection for part of their execution (pool can be smaller).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With