From 989f0c6f5a377f605e3bde391a5c2ee3fb5128c1 Mon Sep 17 00:00:00 2001 From: elandau Date: Tue, 17 Sep 2019 10:08:54 -0700 Subject: [PATCH 1/2] Ignore cancelled - Stop treating cancelled as timeouts (for gRPC) as poor client behavior can adversely affect the server concurrency limiter - For `gradient` make the backoff ratio for drops configurable and change the default to 0.9 (from 0.5) since the current default can result in overly aggressive load shedding. --- .../limits/limit/GradientLimit.java | 20 +++++++++++++++++-- concurrency-limits-grpc/build.gradle | 2 +- .../ConcurrencyLimitServerInterceptor.java | 1 - 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limit/GradientLimit.java b/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limit/GradientLimit.java index df07f045..fe6d5969 100644 --- a/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limit/GradientLimit.java +++ b/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limit/GradientLimit.java @@ -52,6 +52,7 @@ public static class Builder { private MetricRegistry registry = EmptyMetricRegistry.INSTANCE; private double rttTolerance = 2.0; private int probeInterval = 1000; + private double backoffRatio = 0.9; /** * Minimum threshold for accepting a new rtt sample. Any RTT lower than this threshold @@ -153,6 +154,18 @@ public Builder metricRegistry(MetricRegistry registry) { this.registry = registry; return this; } + + /** + * Ratio applied to the limit when a timeout was identified within the sampling window. The default value is + * 0.9. A value of 1.0 means no backoff. + * @param backoffRatio + * @return + */ + public Builder backoffRatio(double backoffRatio) { + Preconditions.checkArgument(backoffRatio >= 0.5 && backoffRatio <= 1.0, "backoffRatio must be in the range [0.5, 1.0]"); + this.backoffRatio = backoffRatio; + return this; + } @Deprecated public Builder probeMultiplier(int probeMultiplier) { @@ -205,6 +218,8 @@ public static GradientLimit newDefault() { private final double rttTolerance; + private final double backoffRatio; + private final SampleListener minRttSampleListener; private final SampleListener minWindowRttSampleListener; @@ -212,7 +227,7 @@ public static GradientLimit newDefault() { private final SampleListener queueSizeSampleListener; private final int probeInterval; - + private int resetRttCounter; private GradientLimit(Builder builder) { @@ -223,6 +238,7 @@ private GradientLimit(Builder builder) { this.queueSize = builder.queueSize; this.smoothing = builder.smoothing; this.rttTolerance = builder.rttTolerance; + this.backoffRatio = builder.backoffRatio; this.probeInterval = builder.probeInterval; this.resetRttCounter = nextProbeCountdown(); this.rttNoLoadMeasurement = new MinimumMeasurement(); @@ -272,7 +288,7 @@ public int _update(final long startTime, final long rtt, final int inflight, fin double newLimit; // Reduce the limit aggressively if there was a drop if (didDrop) { - newLimit = estimatedLimit/2; + newLimit = estimatedLimit * backoffRatio; // Don't grow the limit if we are app limited } else if (inflight < estimatedLimit / 2) { return (int)estimatedLimit; diff --git a/concurrency-limits-grpc/build.gradle b/concurrency-limits-grpc/build.gradle index 5d259967..be045bd4 100644 --- a/concurrency-limits-grpc/build.gradle +++ b/concurrency-limits-grpc/build.gradle @@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8 dependencies { compile project(":concurrency-limits-core") - compile "io.grpc:grpc-core:1.9.0" + compileOnly "io.grpc:grpc-core:1.9.0" testCompile project(":concurrency-limits-spectator") diff --git a/concurrency-limits-grpc/src/main/java/com/netflix/concurrency/limits/grpc/server/ConcurrencyLimitServerInterceptor.java b/concurrency-limits-grpc/src/main/java/com/netflix/concurrency/limits/grpc/server/ConcurrencyLimitServerInterceptor.java index dde8b34f..3627cce2 100644 --- a/concurrency-limits-grpc/src/main/java/com/netflix/concurrency/limits/grpc/server/ConcurrencyLimitServerInterceptor.java +++ b/concurrency-limits-grpc/src/main/java/com/netflix/concurrency/limits/grpc/server/ConcurrencyLimitServerInterceptor.java @@ -160,7 +160,6 @@ public void close(Status status, Metadata trailers) { } finally { safeComplete(() -> { switch (status.getCode()) { - case CANCELLED: case DEADLINE_EXCEEDED: listener.onDropped(); break; From faf473c1751c64ac42cdcd070ae25dd0fddb90b6 Mon Sep 17 00:00:00 2001 From: elandau Date: Tue, 17 Sep 2019 10:15:09 -0700 Subject: [PATCH 2/2] Switch to openjdk8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index def0bc31..fcad80f7 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: java jdk: -- oraclejdk8 +- openjdk8 sudo: false install: "./installViaTravis.sh" script: "./buildViaTravis.sh"