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

Prevent fill-in the threads queue under high load pressure (MongoWaitQueueFullException)

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.16.0
    • Labels:
      None

      Hi,

      I had to implement an unique id generator, I chose to made it with MongoDb in C# (.net 6) using the official tutorial (https://www.mongodb.com/docs/v3.0/tutorial/create-an-auto-incrementing-field/).

      I then decided to put the system under pressure, and I quickly being thrown the MongoWaitQueueFullException => the wait queue for acquiring a connection to server is full.

      After searching a lot on this subject (tasks like https://jira.mongodb.org/browse/CSHARP-118 and a lot from SO), I came to the conclusion that too many threads (coming from the same client instance ?) leads to this behavior and besides possible client settings like increasing the WaitQueueSize property, which it's deprecated and that will disappear soon, it's not a long term solution.

      One possibility is to manage incoming traffic, throttling threads (using SemaphoreSlim for example). It works perfectly but it's not ouf of the box from the driver side.

       

      Then I tried with the exact same client parameters with a Go implementation. I expected to have the exact same kind of behavior under high load pressure, but it worked out of the box.

      So my question is : what is the main difference between both C# and Go implementation that made use implementing a thread throttling in C# where in Go it's not necessary ? Is it possible to be explicit about it in the documentation with some examples for new comers in mongo C# driver ?

      I create minimal reproductible samples here if you need to try by yourself :

      https://github.com/NicolasREY69330/IdGenerator

       

      Thank you guys for your great job

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            nicolas.rey@interflora.fr Nicolas Rey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: