Skip to content

High number of connections due to mongo health indicator #50727

Closed as not planned

Description

@fstaudt

Hello,

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

Activity

  1. added
    status: waiting-for-triage
    on Jun 9, 2026
  2. Yahya-Cheikh-Maazouz commented on Jun 9, 2026

    @Yahya-Cheikh-Maazouz

    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.

  3. fstaudt commented on Jun 9, 2026

    @fstaudt
    Author

    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

  4. added
    type: regression
    and removed
    status: waiting-for-triage
    on Jun 9, 2026
  5. added this to the 4.0.x milestone on Jun 9, 2026
  6. wilkinsona commented on Jun 9, 2026

    @wilkinsona
    Member

    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).

  7. wilkinsona commented on Jun 10, 2026

    @wilkinsona
    Member

    Closing in favor of #50734.

  8. added
    status: superseded
    and removed
    type: regression
    on Jun 10, 2026
  9. removed this from the 4.0.x milestone on Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: superseded

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions