What is the best way to setup your pool with respect to:-
I believe this is an agnostic question, but comments about "features" of particular databases/languages are welcome. For example, it might be slower or more expensive to connect on some databases than others.
To clarify, I do not intend to write a pool from scratch, this question is more about how to configure an existing library that does pooling.
What is database connection pooling? Database connection pooling is a way to reduce the cost of opening and closing connections by maintaining a “pool” of open connections that can be passed from database operation to database operation as needed.
If the maximum pool size has been reached and no usable connection is available, the request is queued. The pooler then tries to reclaim any connections until the time-out is reached (the default is 15 seconds). If the pooler cannot satisfy the request before the connection times out, an exception is thrown.
The default connection pool in Spring Boot 2 is HikariCP. It provides enterprise-ready features and better performance. HikariCP is a JDBC DataSource implementation that provides a connection pooling mechanism. If the HikariCP is present on the classpath, the Spring Boot automatically configures it.
I wrote a connection pool for the database in Java when it was just a design pattern and not a common library. Now I use the one built into Tomcat.
I used a thread to monitor several aspects of the pool and several parameters to control its behavior...
This served me very well for a couple of years. The highest I ever saw the pool was 151 connections during a wild peek. Usually the pool was at about a dozen during heavy usage and idled down to the minimum three in the early morning hours.
I used Oracle's JDBC thin drivers and connected to an Oracle database.
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