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
356
votes
13 answers

How do I manage MongoDB connections in a Node.js web application?

I'm using the node-mongodb-native driver with MongoDB to write a website. I have some questions about how to manage connections: Is it enough using only one MongoDB connection for all requests? Are there any performance issues? If not, can I setup…
Freewind
  • 193,756
  • 157
  • 432
  • 708
326
votes
15 answers

Connection pooling options with JDBC: DBCP vs C3P0

What is the best connection pooling library available for Java/JDBC? I'm considering the 2 main candidates (free / open-source): Apache DBCP - http://commons.apache.org/dbcp/ C3P0 - http://sourceforge.net/projects/c3p0 I've read a lot about them…
Dema
  • 6,867
  • 11
  • 40
  • 48
276
votes
4 answers

Entity Framework and Connection Pooling

I've recently started to use the Entity Framework 4.0 in my .NET 4.0 application and am curious about a few things relating to pooling. Connection pooling as I know is managed by the ADO.NET data provider, in my case that of MS SQL server. Does…
Noldorin
  • 144,213
  • 56
  • 264
  • 302
212
votes
5 answers

What is database pooling?

I just wanted to know the concept of database connection pooling and how it is achieved.
sagar27
  • 3,121
  • 3
  • 27
  • 37
182
votes
14 answers

Efficient SQL test query or validation query that will work across all (or most) databases

Many database connection pooling libraries provide the ability to test their SQL connections for idleness. For example, the JDBC pooling library c3p0 has a property called preferredTestQuery, which gets executed on the connection at configured…
Rob Hruska
  • 118,520
  • 32
  • 167
  • 192
125
votes
13 answers

How to establish a connection pool in JDBC?

Can anybody provide examples or links on how to establish a JDBC connection pool? From searching google I see many different ways of doing this and it is rather confusing. Ultimately I need the code to return a java.sql.Connection object, but I am…
llm
  • 5,539
  • 12
  • 36
  • 30
124
votes
3 answers

Closing JDBC Connections in Pool

Our standard code section for using JDBC is... Connection conn = getConnection(...); Statement stmt = conn.conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE, …
Manidip Sengupta
  • 3,573
  • 5
  • 25
  • 27
89
votes
4 answers

DBCP - validationQuery for different Databases

I use DBCP pool and I want use testOnBorrow and testOnReturn to test if connection is still valid. Unfortunately I have to set property validationQuery to make it work. Question: What value should be in validationQuery? I know, that: validationQuery…
bugs_
  • 3,544
  • 4
  • 34
  • 39
88
votes
9 answers

Connection pooling in PHP

Is it possible to cache database connections when using PHP like you would in a J2EE container? If so, how?
The Chairman
  • 1,159
  • 1
  • 10
  • 15
85
votes
3 answers

Should I set max pool size in database connection string? What happens if I don't?

This is my database connection string. I did not set max pool size until now. public static string srConnectionString = "server=localhost;database=mydb;uid=sa;pwd=mypw;"; So currently how many connections does my application…
Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
73
votes
6 answers

.NET best practices for MongoDB connections?

I've been playing with MongoDB recently (It's AMAZINGLY FAST) using the C# driver on GitHub. Everything is working just fine in my little single threaded console app that I'm testing with. I'm able to add 1,000,000 documents (yes, million) in under…
71
votes
4 answers

Java JDBC connection pool library choice in 2011/2012?

Which JDBC connection pool library should I use for a new application project (not web application)? Apache DBCP has enough unresolved issues which are pushed until 2.0 I think. C3P0 development seems to be stopped. And both of them looks…
Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
69
votes
4 answers

Change the connection pool size for Python's "requests" module when in Threading

(edit: Perhaps I am wrong in what this error means. Is this indicating that the connection pool at my CLIENT is full? or a connection pool at the SERVER is full and this is the error my client is being given?) I am attempting to make a large…
68
votes
3 answers

Is the Session object from Python's Requests library thread safe?

Python's popular Requests library is said to be thread-safe on its home page, but no further details are given. If I call requests.session(), can I then safely pass this object to multiple threads like so: session = requests.session() for i in…
DJG
  • 6,413
  • 4
  • 30
  • 51
57
votes
6 answers

Celery Worker Database Connection Pooling

I am using Celery standalone (not within Django). I am planning to have one worker task type running on multiple physical machines. The task does the following Accept an XML document. Transform it. Make multiple database reads and writes. I'm…
oneself
  • 38,641
  • 34
  • 96
  • 120
1
2 3
99 100