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
26
votes
1 answer

Celery, Redis and ConnectionPool

I recently had a problem with Celery and Redis : I was using too many connections to my cloud Redis account. I seem to have fixed the problem for now with better settings and a bigger Redis plan. However, it lead me to some experimentation on how…
Noé Malzieu
  • 2,530
  • 3
  • 22
  • 27
26
votes
5 answers

Best practice for reusing SqlConnection

I've come from Java experience and am trying to start with C#. I've read SqlConnection SqlCommand SqlDataReader IDisposable and I can understand that the best practice to connecting to a DB is wrapping SqlConnection, SqlCommand and SqlDataReader in…
Hikari
  • 3,797
  • 12
  • 47
  • 77
26
votes
6 answers

Connection Pool Strategy: Good, Bad or Ugly?

I'm in charge of developing and maintaining a group of Web Applications that are centered around similar data. The architecture I decided on at the time was that each application would have their own database and web-root application. Each…
Drew
  • 15,158
  • 17
  • 68
  • 77
25
votes
5 answers

What is the benefit of Connection and Statement Pooling?

Can someone explain what is Connection and Statement Pooling and what is the benefit over unpooled DataSources? I am trying to understand when it is a good idea to use a technology like c3p0 or proxool in a project. I need first to understand what…
user56642
  • 301
  • 1
  • 4
  • 6
25
votes
2 answers

Connection Timeout and Connection Lifetime

What is the advantage and disadvantage of connection timeout=0? And what is the use of Connection Lifetime=0? e.g (Database=TestDB; port=3306; Uid=usernameID; Pwd=myPassword; Server=192.168.10.1; Pooling=false; Connection Lifetime=0; …
Mark
  • 421
  • 5
  • 11
  • 16
24
votes
3 answers

DataSource or ConnectionPoolDataSource for Application Server JDBC resources

When creating JNDI JDBC connection pools in an application server, I always specified the type as javax.sql.ConnectionPoolDataSource. I never really gave it too much thought as it always seemed natural to prefer pooled connections over…
Vinnie
  • 12,400
  • 15
  • 59
  • 80
24
votes
3 answers

Missing connections in tomcat jdbc connection pool

We just migrated from dbcp to tomcat jdbc connection pooling. We tried the system in load and received the following exception: java.sql.SQLException: [IA1856] Timeout: Pool empty. Unable to fetch a connection in 1 seconds, none available[size:125;…
yael alfasi
  • 692
  • 1
  • 4
  • 13
23
votes
7 answers

Tomcat Connection pool creating too many connections, stuck in sleep mode

I'm using Tomcat 6.0.29, with Tomcat 7's connection pool and MySQL. Testing my application, it doesn't reuse anything from the pool, but ends up creating a new pool, to eventually where I cannot use the database because there are hundreds of…
meatyowllegs
  • 231
  • 1
  • 3
  • 5
23
votes
1 answer

Maximum Connection Pool Size

I came across below text while reading about Database Connection pool properties: The maximum pool size property specifies the maximum number of available and borrowed (in use) connections that a pool maintains. If the maximum number of connections…
Vicky
  • 5,380
  • 18
  • 60
  • 83
23
votes
1 answer

Long lasting 'COMMIT' queries with 'idle' state in pg_stat_activity

If I query: select * from pg_stat_activity where application_name ~ 'example-application'; I get many rows which state is idle and query is COMMIT. They are long lasting and do not disappear. After some time, my application reach…
Justinas Jakavonis
  • 8,220
  • 10
  • 69
  • 114
23
votes
4 answers

How do I create a MySQL connection pool while working with NodeJS and Express?

I am able to create a MySQL connection like this: var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : 'me', password : 'secret', database :…
Utkarsh Kaushik
  • 901
  • 1
  • 6
  • 14
23
votes
2 answers

How do I configure HikariCP and Dropwizard/Coda-Hale metrics in Spring Boot application

Reading the instructions on the HikariCP wiki about how to enable the Dropwizard metrics, it says to just configure a MetricsRegistry instance in HikariConfig or HikariDatasource. Problem is, in Spring Boot, all the configuration is handled by…
Kevin M
  • 2,717
  • 4
  • 26
  • 31
23
votes
2 answers

AKKA Actor and DataBase Operation

I'm trying to figure out how to best handle database operations while using an actor system. indeed database operations are blocking while we try not to block in AKKA. I red in the main doc that one way to handle that was to create one a pool of…
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
23
votes
3 answers

How to use RestTemplate efficiently in Multithreaded environment?

I am working on a project in which I need to make a HTTP URL call to my server which is running Restful Service which returns back the response as a JSON String. Below is my main code which is using the future and callables - public class…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
23
votes
4 answers

How to access MySQL from multiple threads concurrently

We're doing a small benchmark of MySQL where we want to see how it performs for our data. Part of that test is to see how it works when multiple concurrent threads hammers the server with various queries. The MySQL documentation (5.0) isn't really…
Isak Savo
  • 34,957
  • 11
  • 60
  • 92