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

The driver could possibly use less threads for background operations

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

    Description

      Hi!

      Currently, MongoDB driver starts multiple separate threads for background activities:
      connection pool maintenance, roundtrip monitor and heartbeat. When an application is using multiple instances of MongoDB, especially replica sets, the number of these threads grows quickly; in one of the recent dumps I've been looking at when debugging another issue, I encountered 162 threads dedicated to MongoDB (of ~300 threads in total for a loaded web app backend).

      I understand why the driver does not use built-in thread pool – it can be starved by application tasks and the driver itself could starve it when there is a spike of new servers – having dedicated threads solves this issue. But the current numbers of threads that mostly sit there waiting for something, occupying stack space still looks suboptimal to me. I undestand that there is nothing wrong with threads from a functional standpoint, but still hope that you would consider reducing the number of threads used for background operations, by either combining multiple tasks into one thread, using some kind of task queue or any other option that you see fit.

      Attachments

        Activity

          People

            boris.dogadov@mongodb.com Boris Dogadov
            onyxmaster Aristarkh Zagorodnikov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: