I have been monitoring my application’s r2dbc_pool_idle_connections metric in Grafana and noticed an interesting behavior.
My application sends queries to the database once or twice a day.
And R2DBC connection pool seems to create connections when they are required.
However, instead of creating just one connection, it creates connections up to the min-idle value specified in my application.yml.
After a database query, the min-idle count drops to zero an hour later (I think it’s because of the default max-idle-time option)
r2dbc:
url: r2dbc:mysql://url:3306/db
username: id
password: pw
pool:
enabled: true
initial-size: 5
min-idle: 5
max-size: 10
I have two questions in the above situation.
1. Does initializing multiple connections up to the min-idle value affect the response time of the request that triggers connection creation?
- For example, if min-idle is set to 100:
- Request -> create 100 connections -> slow response time?
2. Maintaining Idle Connections:
Is there a way to keep the number of idle connections not to zero?
this is my library
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
implementation("com.github.jasync-sql:jasync-r2dbc-mysql:2.1.23")
-
How to keep the number of connections in the connection pool as minidle even if the DB query is unaligned for a long time
-
Does the feature of r2dbc making multiple at once affect response time when creating a connection?