summaryrefslogtreecommitdiffstats
path: root/node-repository/src/main
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-08-09 13:46:56 +0200
committerJon Bratseth <bratseth@gmail.com>2022-08-09 13:46:56 +0200
commit180a265397ab329ae8f8f34f68cae09d48790785 (patch)
treeedb0ebb37b9607b6011dc9e8c5bd9d5d986130ba /node-repository/src/main
parent5be0e33d7e749858f107e9ffa1446fb615801e69 (diff)
Scale down when we have sufficient confidence
Diffstat (limited to 'node-repository/src/main')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java27
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Load.java5
2 files changed, 22 insertions, 10 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java
index 9b9b7dcecb0..5dbc6465411 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java
@@ -9,6 +9,7 @@ import com.yahoo.vespa.hosted.provision.applications.ScalingEvent;
import java.time.Clock;
import java.time.Duration;
+import java.time.Instant;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.logging.Level;
@@ -94,15 +95,31 @@ public class ClusterModel {
/** Returns the relative load adjustment that should be made to this cluster given available measurements. */
public Load loadAdjustment() {
if (nodeTimeseries().measurementsPerNode() == 0) return Load.one(); // No info, no change
+
+ Load peak = nodeTimeseries().peakLoad().divide(idealLoad()); // Peak relative to ideal
+
// Should we scale up?
- Load relativePeak = nodeTimeseries().peakLoad().divide(idealLoad());
- if (relativePeak.any(v -> v > 1.01)) // "meaningful growth": 1% over status quo.
- return relativePeak.max(Load.one()); // Don't downscale any dimension if we upscale
+ if (peak.any(v -> v > 1.01)) // "meaningful growth": 1% over status quo.
+ return peak.map(v -> v < 1 ? 1 : v); // Don't downscale any dimension if we upscale
// Should we scale down?
- // TODO
+ if (canScaleDown())
+ return averageLoad().divide(idealLoad());
+
+ return Load.one();
+ }
+
+ /** Are we in a position to make decisions to scale down at this point? */
+ private boolean canScaleDown() {
+ if (hasScaledIn(scalingDuration().multipliedBy(3))) return false;
+ if (nodeTimeseries().measurementsPerNode() < 4) return false;
+ if (nodeTimeseries().nodesMeasured() != nodeCount()) return false;
+ return true;
+ }
- return averageLoad().divide(idealLoad());
+ private boolean hasScaledIn(Duration period) {
+ return cluster.lastScalingEvent().map(event -> event.at()).orElse(Instant.MIN)
+ .isAfter(clock.instant().minus(period));
}
/** Returns the predicted duration of a rescaling of this cluster */
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Load.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Load.java
index 88c7e70cd35..6ab5ff731d3 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Load.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Load.java
@@ -54,11 +54,6 @@ public class Load {
return new Load(divide(cpu, resources.vcpu()), divide(memory, resources.memoryGb()), divide(disk, resources.diskGb()));
}
- /** Returns the load having the max value of this and the given load in each dimension. */
- public Load max(Load other) {
- return join(other, (a, b) -> Math.max(a, b));
- }
-
/** Returns the load where the given function is applied to each dimension of this. */
public Load map(DoubleUnaryOperator f) {
return new Load(f.applyAsDouble(cpu),