Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1211

ProxyConnectionPool closes connection before it reaches its ttl

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • 2.0.0.Beta1, 1.4.21.Final
    • 1.4.20.Final
    • Proxy
    • None

      The ProxyConnectionPool closes a connection before it reaches its ttl. This causes performance issues and unnecessarily consumes cpu, memory and network resources.

      In an Undertow setup with 1 IO thread, 2 cached connections and mod_cluster backend ttl set to 10s, Apache HTTP server benchmarking tool load tests reveal:

      • 1 connection: all good, no connections closed
      • 2 concurrent connections: all good, no connections closed
      • 3 or more concurrent connections: connections closed before their ttl is reached (state TIME_WAIT)

      I pinpointed the code responsible for this:

      ProxyConnectionPool.java
      final int cachedConnectionCount = hostData.availableConnections.size();
      if (cachedConnectionCount >= maxCachedConnections) {
          // Close the longest idle connection instead of the current one
          final ConnectionHolder holder = hostData.availableConnections.poll();
          if (holder != null) {
              IoUtils.safeClose(holder.clientConnection);
          }
      }
      

      The issue can be solved either by removing the code, or by putting it in an if statement that checks for ttl == 0. But that depends on the interpretation of ttl.
      So does a ttl of 0s mean never expire, or expire immediately? Please let me know.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              frapex Frank de Jong (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: