-2

I have given the required spring boot properties, and enabled the hikari debug as well. However when I start the application, the connection pool is at default itself. Here are the list of properties I am using:

spring.datasource.hikari.connectionTimeout=30000
spring.datasource.hikari.maximumPoolSize=30
spring.datasource.hikari.idleTimeout=600000
spring.datasource.hikari.minimumIdle=15
logging.level.com.zaxxer.hikari.HikariConfig=DEBUG
logging.level.com.zaxxer.hikari=TRACE

For DataSource:

spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:file:D:/ATOP_BACKEND/database/db;AUTO_SERVER=TRUE
spring.datasource.username=sa
spring.datasource.password=
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console

I have tried with various properties, like "spring.datasource.hikari.maximum-Pool-Size=30" and also tried removing hikari as well from the properties(spring.datasource.maximum-Pool-Size) as it seems to have worked in some cases. None of them are increasing the connection pool. Any comments/links would be helpful. After Starting the application the debug message says:

{"@timestamp":"2021-09-13T12:46:51.356+05:30","@version":"1","message":"HikariPool-1 - Pool stats (total=10, active=0, idle=10, waiting=0)","logger_name":"com.zaxxer.hikari.pool.HikariPool","thread_name":"HikariPool-1 housekeeper","level":"DEBUG","level_value":10000,"application_name":"atopweb"}
Rik
  • 81
  • 1
  • 15

1 Answers1

0

I think you need to refer the the documentation of Hikari in order to really understand what is going on.

Setting the value of maxPoolSize to 30 does not mean that the application will start using 30 connections right away. As the documentation states, this property configures the following behavior:

This property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections. Basically this value will determine the maximum number of actual connections to the database backend. A reasonable value for this is best determined by your execution environment. When the pool reaches this size, and no idle connections are available, calls to getConnection() will block for up to connectionTimeout milliseconds before timing out

What this means in short is that the application's connection pool size will be allowed to reach 30 connections should the need for this arises, it does not mean that the application will start using 30 connections right away.

Aside from the above, I suggest you have a look at this piece of documentation that explains the logic behind connection pooling, as well as the various considerations one needs to keep in mind before configuring a connection pool.

akortex
  • 5,067
  • 2
  • 25
  • 57
  • Thanks for your answer. I did take a look at those. Also I have edited my question for the output I was seeing in the debug. Maybe that will give you better clarity. – Rik Sep 13 '21 at 07:30
  • Again the answer above covers what you ask. The size will be 10 and will gradually increase to 30 should the need is there. – akortex Sep 13 '21 at 07:32
  • The maximum (i.e ceiling) will be 30. – akortex Sep 13 '21 at 07:34
  • The properties are not getting overridden. I specified that maximumConnectionPool and minimumIdle should be 30. Both of them are showing as 10, which are the default values. Kindly check the output I gave in the question above. – Rik Sep 13 '21 at 07:36