Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8297558

Reduce Default Keep-Alive Timeout Value for httpclient

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 20
    • core-libs
    • behavioral
    • minimal
    • Hide
      It's unlikely that user code could depend on 1200s idle timeout. New connections will be created when needed, and 30s is long enough to not cause any performance issue. The `jdk.httpclient.keepalive.timeout` system property can be used to configure a different timeout if needed by applications.
      Show
      It's unlikely that user code could depend on 1200s idle timeout. New connections will be created when needed, and 30s is long enough to not cause any performance issue. The `jdk.httpclient.keepalive.timeout` system property can be used to configure a different timeout if needed by applications.
    • Other
    • JDK

      Summary

      This change reduces the current default Keep Alive Timeout value from 1200 seconds to 30 seconds. Idle connections maintained by the httpclient under both HTTP/1.1 and HTTP/2 will be closed if they stay idle for more than 30 seconds if the default value is used.

      Problem

      The current default Keep Alive Timeout value of 1200 seconds is uneccessarily high. This means that when a remote allows the client to specify a Keep Alive time (particularly with HTTP/1.1), a client will wait the entire 1200 second duration to close the idle connection even if the server has already dropped it silently. This would be an expected occurence with common load balancer implementations experiencing high demmand having a need to silently drop client connections.

      Solution

      The default value for Keep Alive timeouts with the httpclient has been reduced from 1200 seconds to 30 seconds, significantly decreasing the duration before idle connections (for both HTTP/1.1 and HTTP/2) are closed by default.

      Specification

      This following change to the specification is located in src/java.net.http/share/classes/module-info.java:99

       - * <li><p><b>{@systemProperty jdk.httpclient.keepalive.timeout}</b> (default: 1200)<br>
       + * <li><p><b>{@systemProperty jdk.httpclient.keepalive.timeout}</b> (default: 30)<br>
         * The number of seconds to keep idle HTTP connections alive in the keep alive cache. This property
         * applies to both HTTP/1.1 and HTTP/2. The value for HTTP/2 can be overridden with the
         * jdk.httpclient.keepalive.timeout.h2 property.
         * </li>

      This specification change will be carried out by this fix JDK-8297030 or by JDK-8296804 depending on whether or not JDK-8297030 is merged first.

            ccleary Conor Cleary (Inactive)
            ccleary Conor Cleary (Inactive)
            Daniel Fuchs, Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: