You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The caching mechanism used by. HttpClientRequest.discoverHttpImplementation() is not working. We end up paying significant cost , when the “HelidonProperties.PROTOCOL_ID” is not explicitly set in Client Config, as it ends up making a new connection on a per request basis to discover the supported HTTP version. This connection is closed ( connection.closeResource() -> socket.close() ) after retrieving the protocol details and this happens on every request .
This is a huge overhead, especially when HTTPS endpoints are involved. This will result in SSL handshake for each such connections.
public class HttpClientRequest extends ClientRequestBase<HttpClientRequest, HttpClientResponse> {
…….. private final LruCache<EndpointKey, HttpClientSpi> clientSpiCache = LruCache.create();
private final WebClient webClient;
The clientSpiCache ideally should be static member so that cached content persists across requests. We did try out tests with this change where made this as static member so that cache is reused across requests. , This. significantly improves the performance.
Based on our tests with the sample, we. see about 47% improvement in throughput, changing the clientSpiCache to static member.
The text was updated successfully, but these errors were encountered:
vasanth-bhat
changed the title
LRU cache clientSpiCache in HttpClientRequest.discoverHttpImplementation() is not workign as new instances are re-created every request
LRU cache clientSpiCache in HttpClientRequest.discoverHttpImplementation() is not working as new instances are re-created every request
Jul 1, 2024
Environment Details
The caching mechanism used by. HttpClientRequest.discoverHttpImplementation() is not working. We end up paying significant cost , when the “HelidonProperties.PROTOCOL_ID” is not explicitly set in Client Config, as it ends up making a new connection on a per request basis to discover the supported HTTP version. This connection is closed ( connection.closeResource() -> socket.close() ) after retrieving the protocol details and this happens on every request .
This is a huge overhead, especially when HTTPS endpoints are involved. This will result in SSL handshake for each such connections.
It looks like the issue is because the LRU cache “clientSpiCache”. used to cache the protocol version for the endpoints is an instance member and not a static member so we end up creating new empty cache for every HTTP request. https://github.com/helidon-io/helidon/blob/main/webclient/api/src/main/java/io/helidon/webclient/api/HttpClientRequest.java#L35
public class HttpClientRequest extends ClientRequestBase<HttpClientRequest, HttpClientResponse> {
……..
private final LruCache<EndpointKey, HttpClientSpi> clientSpiCache = LruCache.create();
private final WebClient webClient;
The clientSpiCache ideally should be static member so that cached content persists across requests. We did try out tests with this change where made this as static member so that cache is reused across requests. , This. significantly improves the performance.
Based on our tests with the sample, we. see about 47% improvement in throughput, changing the clientSpiCache to static member.
The text was updated successfully, but these errors were encountered: