Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-3103

CMAP should mandate LIFO order for connections

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Component/s: CMAP
    • Needed

      DRIVERS-1886 investigated the impact of LIFO vs FIFO policies in the connection pool but was closed under the assumption that:

        All drivers currently return idle connections from the connection pool in LIFO order

      It was discovered today that the Node driver uses FIFO order for pooled connections (cc: bailey.pearson@mongodb.com). Turns out this was a miscommunication. However I still think it's worthwhile to update the CMAP spec with this clarification.

      We should mandate LIFO order in the CMAP spec. There are a few reasons that LIFO is preferred:

      • LIFO is the only approach that is compatible with maxIdleTimeMS. With FIFO or random order, 1 thread can cycle through 100 connections and keep them alive indefinitely. For example see PYTHON-1663.
      • LIFO can result in better performance on the server. Since the server creates 1 thread per connection, reusing recently used connections allows the server to keep a smaller set of threads executing. This should result in lower overhead. An example could be where 1 task is running operations but there are 100 connections in the pool. With LIFO, the task will be pinned to 1 thread on the server. With FIFO, the task will be round-robined over 100 threads.

            Assignee:
            Unassigned Unassigned
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: