Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-586

LaxConnPool can do a better job of maintaining pool size limits

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.0-beta8
    • 5.0-beta9
    • HttpCore
    • None

    Description

      LaxConnPool intentionally does not make strong guarantees about enforcing the maximum size of the connection pools. However, it has poor behaviour when hit with a block of concurrent requests all at once.

      e.g. if the pool max size is 2, and 20 lease request all arrive concurrently at once, it may well create 20 connections.

      That's because the pool size is limited by the leased size, but there's a gap in the code between testing the size and adding a leased entry:

              if (pending.isEmpty() && leased.size() < max) {
                  final PoolEntry<T, C> entry = new PoolEntry<>(route, timeToLive);
                  addLeased(entry);
      

      Thus multiple threads can concurrently pass the leased.size() < max test and thus all create a new PoolEntry.

      That can be greatly improved by not using the leased.size() to track pool size, but to have a separate explicit AtomicInteger counting the number of created PoolEntries.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              linton.miller Linton Miller
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m