aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2023-05-15 15:12:07 +0200
committerGitHub <noreply@github.com>2023-05-15 15:12:07 +0200
commit73ee40ae9013406deb7d75fe9f340efbee526613 (patch)
tree3d149eedfba854bab5af91a4e74ef0c9559144d6
parentd58574e665bdb85a8679da63bb948c349bd2109e (diff)
parent139c483e0cda48685f29df6aaf42b315e482b5cb (diff)
Merge pull request #27118 from vespa-engine/jonmv/random-connection-ttl-variations
Initiate connections shutdown uniform-randomly up to 10% before conn TTL expiry
-rw-r--r--container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java b/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java
index f9a2e3bc1a6..b92a723fac8 100644
--- a/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java
+++ b/container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java
@@ -163,7 +163,8 @@ class HttpRequestDispatch {
double maxConnectionLifeInSeconds = connectorConfig.maxConnectionLife();
if (maxConnectionLifeInSeconds > 0) {
long createdAt = connection.getCreatedTimeStamp();
- Instant expiredAt = Instant.ofEpochMilli((long) (createdAt + maxConnectionLifeInSeconds * 1000));
+ long tenPctVariance = connection.hashCode() % 10; // should be random enough, and must be consistent for a given connection
+ Instant expiredAt = Instant.ofEpochMilli((long) (createdAt + maxConnectionLifeInSeconds * 10 * (100 - tenPctVariance)));
boolean isExpired = Instant.now().isAfter(expiredAt);
if (isExpired) {
gracefulShutdown(connection);