diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2023-05-15 15:12:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-15 15:12:07 +0200 |
commit | 73ee40ae9013406deb7d75fe9f340efbee526613 (patch) | |
tree | 3d149eedfba854bab5af91a4e74ef0c9559144d6 | |
parent | d58574e665bdb85a8679da63bb948c349bd2109e (diff) | |
parent | 139c483e0cda48685f29df6aaf42b315e482b5cb (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.java | 3 |
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); |