From 951b86bbe849fdf81aa25a917d4157c9cf52d173 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Tue, 1 Jun 2021 21:57:29 +0200 Subject: Add back target inflight increase on success --- .../src/main/java/ai/vespa/feed/client/FeedClient.java | 2 +- .../src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/FeedClient.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/FeedClient.java index 1b616a70da9..455a79060ee 100644 --- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/FeedClient.java +++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/FeedClient.java @@ -20,7 +20,7 @@ public interface FeedClient extends Closeable { default boolean retry(OperationType type) { return true; } /** Number of retries per operation for non-backpressure problems. */ - default int retries() { return 5; } + default int retries() { return 32; } } diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java index 17edfeafba6..d43edc9656b 100644 --- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java +++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java @@ -14,6 +14,7 @@ import java.util.function.BiConsumer; import java.util.logging.Logger; import static java.lang.Math.max; +import static java.lang.Math.min; import static java.util.logging.Level.INFO; /** @@ -45,16 +46,15 @@ class HttpRequestStrategy implements RequestStrategy { HttpRequestStrategy(FeedClientBuilder builder) { this.wrapped = builder.retryStrategy; this.maxInflight = builder.maxConnections * (long) builder.maxStreamsPerConnection; - this.minInflight = builder.maxConnections * (long) Math.min(16, builder.maxStreamsPerConnection); + this.minInflight = builder.maxConnections * (long) min(16, builder.maxStreamsPerConnection); this.targetInflight = Math.sqrt(maxInflight) * (Math.sqrt(minInflight)); } private boolean retry(SimpleHttpRequest request, int attempt) { if (attempt >= wrapped.retries()) return false; - - switch (request.getMethod().toUpperCase()) { + switch (request.getMethod().toUpperCase()) { case "POST": return wrapped.retry(FeedClient.OperationType.put); case "PUT": return wrapped.retry(FeedClient.OperationType.update); case "DELETE": return wrapped.retry(FeedClient.OperationType.remove); @@ -81,6 +81,7 @@ class HttpRequestStrategy implements RequestStrategy { synchronized (lock) { ++consecutiveSuccesses; lastSuccess = now; + targetInflight = min(targetInflight + 0.1, maxInflight); } } -- cgit v1.2.3