You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
High number of connections due to mongo health indicator #50727
we noticed a high number of connections created by our microservices after migrating to Spring Boot 4.0.6.
We have about 80 microservices in our product and they used to create around 200 connections to MongoDB.
After migrating to Spring Boot 4, we noticed that microservices were creating around 1300 connections.
After analysis, we identified the mongo health indicator as the root cause of this issue, more precisely the refactoring done with #47051.
Our context:
every microservice has its own database
our microservices use the reactive mongo health indicator to check database connectivity
all microservices in a Kubernetes namespace use the same MongoDB user (to avoid limitation in MongoDB Atlas)
With Spring Boot 3, the mongo health indicator was running a single HELLO command in the database of the microservice.
Since Spring Boot 4, the reactive indicator runs a HELLO command on all databases of the namespace (around 80) and it does so in parallel for the reactive health indicator (due to usage of flatMap).
To fix the issue, we overwrote the mongo health indicator to only check the current database.
Would you consider reverting mongo indicators (blocking & reactive) to their previous implementation (using mongoTemplate & reactiveMongoTemplate) ?
Hi,
We are experiencing the exact same N×M connection explosion issue across our microservices after migrating to Spring Boot 4. We haven't been able to figure out a solid fix for this yet.
Hi, We are experiencing the exact same N×M connection explosion issue across our microservices after migrating to Spring Boot 4. We haven't been able to figure out a solid fix for this yet.
On our side, we added a mongoHealthIndicator bean in our shared libraries with a copy of MongoReactiveHealthIndicator as it was on Spring Boot 3.5 to override the one provided by spring boot 4
Would you consider reverting mongo indicators (blocking & reactive) to their previous implementation (using mongoTemplate & reactiveMongoTemplate) ?
Only as a last resort. We'd prefer to allow the health indicator to be used without Spring Data MongoDB (a step forwards) without the unintentional increase in connection usage (a step backwards).
Activity
Yahya-Cheikh-Maazouz commentedon Jun 9, 2026
Hi,
We are experiencing the exact same N×M connection explosion issue across our microservices after migrating to Spring Boot 4. We haven't been able to figure out a solid fix for this yet.
fstaudt commentedon Jun 9, 2026
On our side, we added a mongoHealthIndicator bean in our shared libraries with a copy of MongoReactiveHealthIndicator as it was on Spring Boot 3.5 to override the one provided by spring boot 4
wilkinsona commentedon Jun 9, 2026
Only as a last resort. We'd prefer to allow the health indicator to be used without Spring Data MongoDB (a step forwards) without the unintentional increase in connection usage (a step backwards).
wilkinsona commentedon Jun 10, 2026
Closing in favor of #50734.