Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What really is connection pooling?

Tags:

I have heard the term connection pooling and looked for some references by googling it... But can't get the idea when to use it....

  • When should i consider using connection pooling?

  • What are the advantages and disadvantagesof connection pooling?

Any suggestion....

like image 232
bala3569 Avatar asked Mar 02 '10 04:03

bala3569


People also ask

What does connection pooling do?

Connection pooling is a technique of creating and managing a pool of connections that are ready for use by any thread that needs them. Connection pooling can greatly increase the performance of your Java application, while reducing overall resource usage.

When should I use connection pooling?

Connection pooling is great for scalability - if you have 100 threads/clients/end-users, each of which need to talk to the database, you don't want them all to have a dedicated connection open to the database (connections are expensive resources), but rather to share connections (via pooling).

What is the difference between connection and connection pool?

When an application requests a connection from the connection pool, the Pool assigns an available connection. If an unused connection exists, the pool return it. Otherwise, if there is no available connection, the Pool will create a new connection and assigns it to the application as an active connection.

What is connection pooling and why it is used in SQL server?

It manages connections by keeping alive a set of active connections for each given connection configuration. Whenever a user calls Open on a connection, the pooler looks for an available connection in the pool. If a pooled connection is available, it returns it to the caller instead of opening a new connection.


2 Answers

The idea is that you do not open and close a single connection to your database, instead you create a "pool" of open connections and then reuse them. Once a single thread or procedure is done, it puts the connection back into the pool and, so that it is available to other threads. The idea behind it is that typically you don't have more than some 50 parallel connections and that opening a connection is time- and resource- consuming.

like image 95
naivists Avatar answered Dec 11 '22 01:12

naivists


When should i consider using connection pooling?

  • Always for production system.

What are the advantages and disadvantages of connection pooling?

Advantages:

  • Performance. Use a fixed pool of connection and avoid the costly creation and release of connections.
  • Shared infrastructure. If your database is shared between several apps, you don't want one app to exhaust all connections. Pooling help to limit the number of connection per app.
  • Licensing. Depending on your database license, the number of concurrent client is limited. You can set a pool with the number of authorized connections. If no connection is available, client waits until one is available, or times out.
  • Connectivity issue. The connection pool that is between the client and the database, can provide handy features such as "ping" test, connection retry, etc. transparently for the client. In worse case, there is a time-out.
  • Monitoring. You can monitor the pool, see the number of active connections, etc.

Disadvantage:

  • You need to set it up and configure it, which is really peanuts usually.
like image 22
ewernli Avatar answered Dec 11 '22 01:12

ewernli