One of the commonly used components is the JDBC Connection Pool. This critical component provides access to the database through a pool of established connections that can be used by the application.
Why use a connection pool?
Each connection from the application to the database is an independent TCP/IP socket connection. The protocol defines a 3-way SYN handshake to establish a connection. This process takes time. Today, in many cases, the business requires a secure and encrypted connection between the application and database. This requires additional handshakes to negotiate the SSL connection. Since this initial handshake process can take considerable time there is a significant performance advantage to reuse established connections.
How do I implement a connection pool?
By default if you do not provide a connectionManager stanza in your Liberty server.xml it will still create a connection pool with preset defaults. Note that some of the defaults may not be optimal for all environments.
In particular, the minimum pool size is zero which means if the application is idle long enough there will be no connections in the pool. Setting the minimum connection pool size to 5 or 10 can help response times for fairly idle applications. And note it is a lazy minimum which means after application startup it will not create the connections until the application requests them. I just worked on a ticket where the application was seeing longer response times in the off hours. We captured some javacores and noticed quite a few threads were waiting to open a connection to the database. By increasing the minimum pool size from zero to 5 the application was able to keep connections to the database available for immediate reuse.