RFR: 8288717: Add a means to close idle connections in HTTP/2 connection pool
Anton Keks
duke at openjdk.org
Fri Sep 23 07:04:32 UTC 2022
On Thu, 22 Sep 2022 11:19:34 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> IMHO, it would be great to use the same property as for HTTP/1 connections: `jdk.httpclient.keepalive.timeout`
>> People are already expecting it to work with HTTP/2, but to everyone's surprise it doesn't.
>>
>> It would also be nice to support `jdk.httpclient.connectionPoolSize` for HTTP/2 as well, again to avoid surprises.
>>
>> Neither of these properties reference either HTTP/1 or HTTP/2 in their names, so should work for all kinds of connections.
>
>> IMHO, it would be great to use the same property as for HTTP/1 connections: jdk.httpclient.keepalive.timeout
>> People are already expecting it to work with HTTP/2, but to everyone's surprise it doesn't.
>>
>> It would also be nice to support jdk.httpclient.connectionPoolSize for HTTP/2 as well, again to avoid surprises.
>
> Although I also find that the proliferation of properties is a bit distasteful, I have to disagree on this. The HTTP/1.1 and HTTP/2 connection pools are very different in their purpose and function, and it's unlikely that a single value would fit all.
>
> The HTTP/1.1 connection pool contains idle connections. Active connections are not in the pool. The pool may contain several connections to the same server. The HTTP/2 connection pool contains all connections, whether active or idle, but contains only one connection to a given server (it may at most have one TLS and one clear for a given server). The connections remain in the pool when they are in use - because they support multiplexing. There is no notion of "KeepAlive" like in HTTP/1.1, but each peer can close a connection at its own discretion using a GOAWAY frame.
>
> For these reasons I would rather have different properties for configuring the different pools.
@dfuch let's look at why anybody would configure these properties at all: they are having problems in their (cloud) environment with connections open for too long.
If they have a problem, then they would like to shorten life time of (all) idle connecitons.
Now let's assume that somebody used a HTTP/1.1 service via HttpClient. The problem with keepalive was already solved by using the `jdk.httpclient.keepalive.timeout` property.
Then, suddenly the service upgrades to HTTP/2 and stops working again because now the application developers/admins need to understand what happened and introduce another property with the same intention, but a different name.
The point is, most users don't know or care if the services they use are HTTP/1 or HTTP/2 - it should work the same way from the HttpClient API viewpoint.
That being said, please introduce a default value for the new property which is in line with the existing one, e.g. 1200 seconds or something - at least it won't be unlimited, which is not a good default.
-------------
PR: https://git.openjdk.org/jdk/pull/10183
More information about the net-dev
mailing list