What is the working mechanism of the data connection pool?

Source: Internet
Author: User

Database connectivity is a critical, limited, and expensive resource, which is particularly evident in enterprise-class applications. The management of database connections can significantly affect the scalability and robustness of the entire application, affecting the performance of the program. The database connection pool was raised for this issue.

The database connection pool is responsible for allocating, managing, and freeing the database connection, which allows the application to reuse an existing database connection instead of re-establishing a database connection that has been idle for more than the maximum idle time to avoid missing database connections due to the absence of a database connection being freed. This technology can significantly improve the performance of database operations.

The specific working mechanism is as follows:

When the database connection pool is initialized, a certain number of database connections are created in the connection pool, and the number of these database connections is set by the minimum number of database connections. Regardless of whether these database connections are being used, the connection pool will always be guaranteed to have at least so many connections. The maximum number of database connections for a connection pool limits the maximum number of connections that this pool can occupy, and these requests are added to the wait queue when the number of connections requested by the application to the connection pool exceeds the maximum number of connections.

The minimum number of connections and the maximum number of connections for a database connection pool are set to take into account the following factors:

1) The minimum number of connections is the connection pool has been maintained database connection, so if the application to the database connection is not used, there will be a large number of database connection resources are wasted;

2) The maximum number of connections is the maximum number of connections the connection pool can request, and if the database connection request exceeds this number, subsequent database connection requests are added to the wait queue, which affects subsequent database operations.

3) If the minimum number of connections is too large for the maximum number of connections, the first connection request will take profit, and then the connection request that exceeds the minimum number of connections is equivalent to 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.