Questions tagged [connection-pooling]

In software engineering, a connection pool is a cache of connections maintained so that the connections can be reused when future requests to the resource are required.

Description

Connection pools are used to enhance the performance of executing commands on a database or other server. Opening and maintaining a connection for each user especially requests made to a dynamic database-driven website application, is costly and wastes resources.

In connection pooling, after a connection is created, it is placed in the pool and it is used over again so that a new connection does not have to be established. If all the connections are being used, a new connection is made and is added to the pool. Connection pooling also cuts down on the amount of time a user must wait to establish a connection to the resource.


Connection Pool libraries

Java

  • HikariCP
    It is considered as one of the best libraries for connection pooling. Play 2.4 Framework uses HikariCP by default.
    Website, GitHub.

  • BoneCP
    It beats older connection pools such as C3P0 and DBCP but should now be considered deprecated in favour of HikariCP.
    Website, GitHub

  • Apache Commons DBCP
    Website.

  • C3P0
    Website, GitHub

3263 questions
52
votes
2 answers

flask_sqlalchemy `pool_pre_ping` only working sometimes

For testing, I amend the MYSQL (RDS) parameters as follows; wait_timeout = 40 (default was 28800) max_allowed_packet = 1GB (max - just to be sure issue not caused by small packets) net_read_timeout = 10 interactive_timeout unchanged Then tested my…
Anum Sheraz
  • 2,383
  • 1
  • 29
  • 54
48
votes
2 answers

What does sp_reset_connection do?

sp_reset_connection seems to be called by SQL Server connection pooling, to ensure that connections reused from the pool have most of their settings reset. Does anyone know exactly what it does and doesn't do though? eg I see from this post that it…
Rory
  • 40,559
  • 52
  • 175
  • 261
46
votes
3 answers

Hibernate: What is the connection pool and why is the default one unsuitable for production?

I'm very unfamiliar with Hibernate and have just started working on a web app that uses it with a MySQL database. I notice that the community documentation tutorial states: The built-in Hibernate connection pool is in no way intended for…
Kryptic
  • 1,922
  • 2
  • 21
  • 29
46
votes
3 answers

What happens to an uncommitted transaction when the connection is closed?

Are they rolled back immediately? Are they rolled back after some period of time? Are they left in an uncommitted state? Is the behavior the same if connection pooling is used and the connections are simply reset?
JohnnyM
  • 28,758
  • 10
  • 38
  • 37
44
votes
4 answers

Spring JDBC connection pool best practices

I have a basic Spring JDBC application with a pretty basic configuration:
Luciano Fiandesio
  • 10,037
  • 10
  • 48
  • 56
44
votes
3 answers

Why do I constantly see "Resetting dropped connection" when uploading data to my database?

I'm uploading hundreds of millions of items to my database via a REST API from a cloud server on Heroku to a database in AWS EC2. I'm using Python and I am constantly seeing the following INFO log message in the…
Andrew Thompson
  • 2,396
  • 1
  • 21
  • 23
44
votes
8 answers

Optimal number of connections in connection pool

Currently we are using 4 cpu windows box with 8gb RAM with MySQL 5.x installed on same box. We are using Weblogic application server for our application. We are targeting for 200 concurrent users for our application (Obviously not for same…
Silent Warrior
  • 5,069
  • 8
  • 41
  • 52
42
votes
7 answers

How to force a SqlConnection to physically close, while using connection pooling?

I understand that if I instantiate a SqlConnection object, I am really grabbing a connection from a connection pool. When I call Open(), it will open the connection. If I call the Close() or Dispose() method on that SqlConnection object, it is…
Jeff Meatball Yang
  • 37,839
  • 27
  • 91
  • 125
41
votes
9 answers

What is the best solution for database connection pooling in python?

I have developed some custom DAO-like classes to meet some very specialized requirements for my project that is a server-side process that does not run inside any kind of framework. The solution works great except that every time a new request is…
John
  • 14,944
  • 12
  • 57
  • 57
41
votes
6 answers

Springs RestTemplate default connection pool

Just wondering if RestTemplate out of the box uses connection pooling or does it simply establish a new connection each time ?
Sam
  • 861
  • 3
  • 10
  • 16
41
votes
3 answers

what is the use of the pool option in database.yml

Most widely used options in database.yml are of following : adapter encoding database pool username password socket host port timeout I know the use of the most of the above but pool. So i want to know what is the use of the pool option in…
Salil
  • 46,566
  • 21
  • 122
  • 156
39
votes
2 answers

Best configuration of c3p0

I'm struggling with a problem facing c3p0 configuration. I posted a question last week
Babak Behzadi
  • 1,236
  • 2
  • 16
  • 33
39
votes
2 answers

SQLite/C# Connection Pooling and Prepared Statement Confusion

I have been spending some time reading different best practices for databases and for SQLite specifically. While reading I found I was doing many things I shouldn't be doing and when attempting to fix these issues I became confused when thinking…
Lux782
  • 451
  • 1
  • 4
  • 5
37
votes
1 answer

Difference between BasicDatasource and PoolingDatasource

What is the difference between org.apache.commons.dbcp BasicDatasource and PoolingDataSoure? Do both support pooling of connections? When to use each of them ?
sam
  • 651
  • 3
  • 9
  • 16
37
votes
7 answers

Connection pooling in java using HttpClient

How can I create a pool of connections using HttpClient? I have to make frequent connections to the same server. Is it worth creating such a pool? Is it possible to keep HTTP connections live and use them for various requests, and if yes how can I…
John
  • 2,682
  • 5
  • 23
  • 24