How to set number of partition when migrating from BoneCp to HikariCP

100 Views Asked by At

I am in the process of changing BoneCp to access our postgres database to HikariCp. Can someone help me with specifying the partition count in HikariConfig.

From:

            BoneCPConfig config = new BoneCPConfig();
            config.setIdleMaxAge(10, TimeUnit.MINUTES);
            config.setIdleConnectionTestPeriod(30, TimeUnit.SECONDS);
            config.setMaxConnectionAge(30, TimeUnit.MINUTES);
            config.setJdbcUrl(dbUrl);
            config.setMaxConnectionsPerPartition(64);
            config.setMinConnectionsPerPartition(1);
            config.setPartitionCount(4);    <--------- Specified partition count is 4

To:

            HikariConfig hikariConfig = new HikariConfig();
            hikariConfig.setIdleTimeout(Duration.ofMinutes(10).toMillis());
            hikariConfig.setKeepaliveTime(Duration.ofSeconds(30).toMillis());
            hikariConfig.setMaxLifetime(Duration.ofMinutes(30).toMillis());
            hikariConfig.setJdbcUrl(dbUrl);
            hikariConfig.setMaximumPoolSize(64);

What is the equivalent way to setPartitionCount in hikariConfig?

1

There are 1 best solutions below

0
fedden On BEST ANSWER

There is no such concept as connections partitions in HikariCP, so to match number of connections what you want is to set hikariCP maximumPoolSize to be equal to boneCP maxConnectionsPerPartition*PartitionsCount that is 64*4=256 in your case.

Note, that you might not need that big amount of connections anymore as HikariCP should manage them more efficiently, but anyway I wouldn’t advise to change the pool and maximum pool size at once.