hkjaaaip
hkjaaaip

Reputation: 123

r2dbc idle connection count keeps dropping to zero

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?
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")

Upvotes: 0

Views: 115

Answers (0)

Related Questions