1

I am trying to use Hikari for Postgres connection. Here is the setting:

    config.setMinimumIdle(20);
    config.setMaximumPoolSize(100);

However, it only seems to have 2 connections. I got this after ran netstat -ant | grep 5432

tcp4       0      0  127.0.0.1.5432         127.0.0.1.53183        ESTABLISHED
tcp4       0      0  127.0.0.1.53183        127.0.0.1.5432         ESTABLISHED

and also in Postgres console SELECT sum(numbackends) FROM pg_stat_database;

 sum 
 -----
 2

(1 row)

I am not sure what's going on and I appreciate your help!

camus
  • 57
  • 1
  • 8

1 Answers1

0

Recommended setup is to not set minimumIdle

This property controls the minimum number of idle connections that HikariCP tries to maintain in the pool. If the idle connections dip below this value and total connections in the pool are less than maximumPoolSize, HikariCP will make a best effort to add additional connections quickly and efficiently. However, for maximum performance and responsiveness to spike demands, we recommend not setting this value and instead allowing HikariCP to act as a fixed size connection pool. Default: same as maximumPoolSize.

Seems HikariCP does not care much about it

If the idle connections dip below this value ... HikariCP will make a best effort to add additional connections

A good test for your value could be to open more than 20 connections and verify they are maintained in the pool during idleTimeout (10 minutes by default). Then the value should be kept at the setting value (20 in this case).

That minimum will be maintained once the number of connections reaches that value

Idle connections will not be retired once the pool reaches minimumIdle connections.

LMC
  • 10,453
  • 2
  • 27
  • 52