Database connection pool principle

    The database connection pool will create a certain number of database connections into the connection pool during initialization, and the number of these database connections is restricted by the minimum number of database connections. Regardless of whether these database connections are used, the connection pool will always be guaranteed to have at least this many connections. The maximum number of database connections in the connection pool limits the maximum number of connections that the connection pool can occupy. When the number of connections requested by the application to the connection pool exceeds the maximum number of connections, these requests will be added to the waiting queue.
    The basic idea of ​​the connection pool is to store the database connection as an object in memory when the system is initialized. When the user needs to access the database, instead of establishing a new connection, an established idle connection object is taken out from the connection pool. . After use, the user does not close the connection, but puts the connection back into the connection pool for the next request to access. The establishment and disconnection of connections are managed by the connection pool itself. At the same time, you can also control the initial number of connections in the connection pool, the upper and lower limits of the connection, the maximum number of times each connection is used, the maximum idle time, etc. by setting the parameters of the connection pool. It can also monitor the number of database connections, usage, etc. through its own management mechanism

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325924226&siteId=291194637