Connection pooling is a concept to save time by not creating object for every database call but to use previously created object i.e. re-usability.
Opening and closing a database connection is significant time consuming process which makes performance of an application slow.
An application server serves the connection pooling request, whenever a database request is received, connection pool is searched for available object and if there are unoccupied object, they are assigned to request, if no idle object is available then the request can be queued & wait until the other object become free to exercise or new connection object will be formed and added in pool.
Note: Creation of new object when no idle object in present in the pool depends upon the configuration of how much object pool can support.
Once the request finishes exercising the connection object, it will be added back to pool, which then will be used by other queued request.
The above process is fairly simple to understand and implies that most of the requests are served using the existing objects which in terms saves time taken to create connection object every time a request come.
|Image source: IBM|