First, the basic principle of connection pooling the idea is that when the system is initialized, the database connection is stored as an object in memory, and when the user needs to access the database, it does not establish a new connection, but instead pulls out an established idle connection object from the connection pool. After use, the user does not close the connection, but instead places the connection in the connection pool for the next request to access it. Connection pooling is managed by the connection pool itself, while connections are established and disconnected. You can also control the number of initial connections in the connection pool, the upper and lower limits of connections, the maximum number of uses per connection, maximum idle time, and so on, by setting parameters for the connection pool. It is also possible to monitor the number, usage, etc. of database connections through its own management mechanism.
Second, commonly used nouns 1, the minimum connection number is the connection pool maintains the database connection, all if the application to the database connection usage is small, will have the massive database connection to be wasted. 2, the maximum number of connections is the connection pool can request the maximum number of connections, if the database connection request exceeds this number, the subsequent database connection request will be added to the waiting queue, which affects the database operations after. 3, the minimum number of connections and the maximum number of connections between the minimum number of connections and the maximum number of connections is too large, then the first connection request will be profitable, and then more than the minimum number of connections please go to the equivalent of establishing a new database connection. However, these database connections that are larger than the minimum number of connections will not be released immediately after they are used, and will be placed in the connection pool for reuse or to be freed after an idle timeout. Third, the advantages of database connection pooling Technology 1, resource reuse due to the reuse of database connections, avoid the frequent creation, release of the connection caused by a large number of performance costs. On the other hand, it improves the smoothness of the system running environment (reduce the memory fragmentation and the number of temporary database processes/threads) on the basis of reducing system consumption. 2. Faster system response Speed database connection pooling during initialization, several database connections are often created to be placed in the pool for backup. The initialization of the connection is now complete. For business request processing, direct utilization of existing available connections avoids the time overhead of database connection initialization and release, thus reducing overall system response time. 3, the new resource allocation means for multiple applications to share the same database system, the application layer through the database connection configuration, database connection pool technology, a few years may be a fresh topic, for the current business system, if the design has not taken into account the application of the connection pool, then ... Add this section to your design documentation. A limit on the maximum number of database connections available to an application to avoid exclusive use of all database resources by an app. 4, unified connection management, to avoid database connection leakage in a more complete database connection pool implementation, according to the pre-connection to occupy the timeout setting, forced to recover the occupied connection. This avoids resource leaks that may occur in regular database connection operations. Understanding the database buffer pool principle we know that every time you connect to a database, you get the idle connection object from the buffer pool and you may not be aware
Database connection Pooling Technology