Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4375

Connection pruner is too aggressive

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Gone away
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      We recently updated from mongodb server 4.2 / mongodb driver 2.12.5 to mongodb server 5.0 / mongodb driver 2.17.0, after which we have observed a rise in timeouts from our applications, and a sawtooth-shape in our open connections graph. (We use an EventSubscriber to keep track of open connections.)

      After some investigation, we see that there is a significant change in how connections are maintained in the ExclusiveConnectionPool.

      v2.12.5 would prune 1 connection at a time (note the break statement in the loop):
      https://github.com/mongodb/mongo-csharp-driver/blob/v2.12.5/src/MongoDB.Driver.Core/Core/ConnectionPools/ExclusiveConnectionPool.cs#L818

      whilst newer versions will quite aggressively remove all expired connections:

      https://github.com/mongodb/mongo-csharp-driver/blob/v2.18.0/src/MongoDB.Driver.Core/Core/ConnectionPools/ExclusiveConnectionPool.Helpers.cs#L707

       

      This is a problem for our applications, which require many open connections (100) at all time. (Our applications handle high spikes of traffic, with quiet periods in between.)

      During quiet periods, MaintenanceHelper (v2.17.0) will periodically remove all existing connections, and spend some time creating new ones. When a traffic spike hits our application at the same time, the application will not be able to serve incoming requests, and we get lots of timeouts.

       

      v2.12.5 of the driver would remove one connection, open one connection, remove one, open one etc, which results in the application always having available open connections.

      v2.17.0 removes all connections at once, which renders our application useless for the next (15-30) seconds.

       

      We rely on MaintenanceHelper maintaining connections "the old way", or we cannot use the driver.

      Attachments

        Activity

          People

            boris.dogadov@mongodb.com Boris Dogadov
            hans.olav.loftum@nrk.no Hans Olav Loftum
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: