The role of database connection pooling

Source: Internet
Author: User
Tags connection pooling

Reference Http://[email protected]/blog/static/93745961201111664310934/

For a simple database reference, the access to the database is not very frequent. At this point, you can simply create a connection when you need to access the database, and then close it when you're done with it, without any noticeable performance overhead. But for a complex database reference, the situation is completely different. Frequent building and closing of connections can greatly reduce the performance of the system, as the use of connections becomes a bottleneck for system performance.

For shared resources, there is a well-known design pattern: a resource pool. This model is to solve the problem caused by the frequent allocation and release of resources. The application of this mode to database connection management is to establish a database connection pool, provide a set of efficient connection allocation, use policy, the ultimate goal is to achieve the efficient and safe reuse of the connection.

The basic principle of database connection pooling is to maintain a certain number of database connections in the internal object pool and expose the database connection acquisition and return methods externally. such as: the external user can obtain the connection through the Getconnection method, and then use the Releaseconnection method to return the connection, note that at this time the connection is not closed, but is collected by the connection pool manager and ready for the next use.

Benefits of database connection pooling technology:

1. Reuse of resources

Due to the reuse of database connections, the high performance overhead caused by frequent creation and release of connections is avoided. 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, it is often that several database connections have been created as well as in the pool standby. The initialization of the connection is now complete. For business request processing, direct utilization of existing available connections avoids the initialization and release time of the database connection, thus reducing the overall response time of the system.

3. Unified connection management to avoid database connection leakage

In a more complete database connection pool implementation, it is possible to forcibly reclaim the occupied connection based on the pre-connection occupancy timeout setting. This avoids resource leaks that may occur in regular database connection operations.

The role of database connection pooling

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: 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.