The role of the Web project connection pool

Source: Internet
Author: User
Tags connection pooling

Connection pooling: A connection pool is a pool of connections that have been created, and when a request comes in, access to the database directly using a connection that has already been created. This omits the process of creating the connection and destroying the connection. This performance has been improved.

The rationale is this:

(1) Establish database connection pool object (server start).
(2) Create the initial number of database connections (that is, the number of idle connections) according to the parameters specified beforehand.
(3) for a database access request, get a connection directly from the connection pool. Create a new database connection if there is no idle connection in the database connection pool object and the number of connections does not reach the maximum (that is, the maximum number of active connections).
(4) access the database.
(5) Close the database, release all database connections (at this point, close the database connection, not really shut down, but put it in an idle queue.) Release the connection if the number of actual idle connections is greater than the number of initial idle connections).
(6) Release the database connection pool object (during server stop, maintenance, release the database connection pool object, and release all connections).

The core function is to improve performance. Reduce overhead.


1. The concept of connection pooling and why use connection pooling?
The connection pool puts N Connection objects, essentially in memory, a cache object in memory, and the application gets Connection objects from the pool every time. Instead of getting it directly from the data, this does not occupy the server's memory resources.

2. What happens if you do not use a connection pool:
A. Server-occupied memory resources
B. Cause the server to be very slow

3. Three ways to apply connection pooling:
A. Custom connection Pooling
B. Using a third-party connection pool
c. Use the server's own connection pool

Connection pooling is generally more advantageous than direct connection,Because it improves performance, it also preserves valuable resources. Throughout the use of the application process,Ofrepeated Open Direct connections will result in degraded performance。 This performance issue is eliminated by pooling connections that are only opened once when the server is started.
        connection pooling is primarily concerned with performance, there is a great amount of work to be performed on each acquisition and release of the connection, which can have a significant impact on performance;ResourcesIt is counterproductive because saving a certain number of connections consumes memory. Each time the application obtains the Connection object from the pool, rather than getting it directly from the data, it does not occupy the server's memory resources. So generally to establish a connection pool, and the number of connections should be appropriate, not too large, too much consumption of resources.( So, consider 2 Aspects, one is memory, the other is the resource )。

Connection pooling is a way to avoid the degradation of performance and the waste of system resources by repeatedly opening database connections.


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.