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

What is the difference between a Session and a Connection in Hibernate?

I want to clear the basic 3 points, Does beginning a new database transaction on an old session obtains a new connection and resumes the session? Does committing a database transaction disconnects a session from the JDBC connection and returns…
19
votes
6 answers

Python mysql (using pymysql) auto reconnect

I'm not sure if this is possible, but I'm looking for a way to reconnect to mysql database when the connection is lost. All the connections are held in a gevent queue but that shouldn't matter I think. I'm sure if I put some time in, I can come up…
19
votes
3 answers

SQL Server connection pool doesn't detect closed connections?

For years, I've experienced very weird problems on all my web applications that connect to a SQL server. The problem is that if something happens to the database server (server restart or other problem), de web app stops working from that point on,…
Philippe Leybaert
  • 168,566
  • 31
  • 210
  • 223
19
votes
3 answers

hibernate default connection pooling

Does Hibernate use connection pool by default? If so what is the default value for *connection.pool_size*? Doesn't it conflicts with *hibernate.connection.release_mode*? Isn't the all idea of connection pooling is not closing connections?
Adi Baron
  • 546
  • 2
  • 5
  • 21
18
votes
4 answers

how to check HikariCP connection pooling is working or not in Java?

I have written following properties in my configuration files I am using Log4j in my application When I am running a project. I am getting following message.does that mean connection pooling is configured in my project? if not then how it will…
Tejal
  • 764
  • 1
  • 10
  • 39
18
votes
2 answers

How can I detect whether my code is running "inside" Sidekiq server or Puma?

I'm using Puma as a web server, and Sidekiq as my queue runner. For multiple things (Database connections, Redis connections, other external services) I'm using the ConnectionPool gem to manage safe access to connections. Now, depending on whether…
Daniel Magliola
  • 30,898
  • 61
  • 164
  • 243
18
votes
2 answers

How to check current pool size of SQL Server

Is there a way to check the current connection pool size in SQL Server? I am not talking about the max connection pool size, but the current pool size. Let's say the max pool size is 100 and there are 49 connections open, it should now show me…
Frank Martin
  • 3,147
  • 16
  • 52
  • 73
18
votes
1 answer

Heroku + Sidekiq: ActiveRecord::StatementInvalid: PG::UnableToSend: SSL SYSCALL error: EOF detected

Hi we are running on Heroku's Cedar stack with Unicorn and Sidekiq. We intermittently get the following errors BurnThis ActiveRecord::StatementInvalid: PG::UnableToSend: SSL SYSCALL error: EOF detected ActiveRecord::StatementInvalid:…
18
votes
4 answers

eclipselink connection pooling

If connection pooling is not defined in the persistence.xml for eclipse link, what is the default behavior? Will it open and close a JDBC connection for every transaction? Will it create a connection pool with some defaults?
user1796571
  • 662
  • 2
  • 9
  • 21
17
votes
3 answers

How to find leaking db connection pool handle?

I'm seeing the dreaded "The timeout period elapsed prior to obtaining a connection from the pool" error. I've searched the code for any unclosed db connections, but couldn't find any. What I want to do is this: the next time we get this error, have…
Jesse
  • 187
  • 1
  • 2
  • 9
17
votes
1 answer

DBCP2 - When are Idle connections removed from the Pool

While configuring DBCP2 pool, and based on documentation I noticed that - there is a configuration called timeBetweenEvictionRunsMillis which is described as: The number of milliseconds to sleep between runs of the idle object evictor thread.…
Wand Maker
  • 18,476
  • 8
  • 53
  • 87
17
votes
2 answers

HikariCP and maxLifetime

I moved my project to HikariCP. Everything is going fine so far, but with one setting I'm having trouble. It's the .setMaxLifetime(30*1000) setting in HikariConfig object. I get this warning WARN com.zaxxer.hikari.HikariConfig - maxLifetime is less…
Gabriel
  • 1,820
  • 2
  • 23
  • 31
16
votes
3 answers

How create an PostgreSQL connection pool using Java?

I'm trying to use a Connection Pool, but I don't understand it right. Who implements it? The software, the driver or the database? How I do to have my program running using a Connection Pool? I'm using the native PostgreSQL driver. I need an code…
Renato Dinhani
  • 35,057
  • 55
  • 139
  • 199
16
votes
1 answer

HikariCP multithreading separate connection for each thread

To the folks of the stackoverflow community. I was looking for some help with an issue i am facing with HikariCP connection pooling. High level: I am trying to create several threads using a thread pool and my plan is to give each worker thread its…
16
votes
1 answer

PoolingHttpClientConnectionManager does not release connections

I am using Spring to achieve the following: On a server, I receive data via a REST interface in an XML-Format. I want to transform the data into JSON and POST it to another Server. My code (I removed some sensitive classnames/URLs to avoid the wrath…