diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2020-03-30 13:44:17 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2020-03-30 13:44:17 +0200 |
commit | e05dbaa1905316939739a04b644a751d4c1a2cce (patch) | |
tree | b89b0c19ad65bc4b95f954cfe78ad65e048f8f6a /node-repository | |
parent | aa052fd6c6df81f07b8dddf8c139b731a710ade2 (diff) |
Avoid small changes when ideal is off limits
Diffstat (limited to 'node-repository')
3 files changed, 22 insertions, 21 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableClusterResources.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableClusterResources.java index 0e4cc8390a2..5ca09ddf51c 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableClusterResources.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableClusterResources.java @@ -116,7 +116,9 @@ public class AllocatableClusterResources { @Override public String toString() { - return "$" + cost() + " (fulfilment " + fulfilment + "): " + realResources(); + return nodes + " nodes with " + realResources() + + " at cost $" + cost() + + (fulfilment < 1.0 ? " (fulfilment " + fulfilment + ")" : ""); } } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Autoscaler.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Autoscaler.java index 9fe1b4ac55d..e8796820fa9 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Autoscaler.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Autoscaler.java @@ -37,10 +37,10 @@ public class Autoscaler { private static final int minimumMeasurements = 500; // TODO: Per node instead? Also say something about interval? - /** What cost difference factor warrants reallocation? */ - private static final double costDifferenceRatioWorthReallocation = 0.1; - /** What difference factor from ideal (for any resource) warrants a change? */ - private static final double idealDivergenceWorthReallocation = 0.1; + /** What cost difference factor is worth a reallocation? */ + private static final double costDifferenceWorthReallocation = 0.1; + /** What difference factor for a resource is worth a reallocation? */ + private static final double resourceDifferenceWorthReallocation = 0.1; private final HostResourcesCalculator resourcesCalculator; private final NodeMetricsDb metricsDb; @@ -82,13 +82,7 @@ public class Autoscaler { currentAllocation, cluster); if (bestAllocation.isEmpty()) return Optional.empty(); - - if (closeToIdeal(Resource.cpu, cpuLoad.get()) && - closeToIdeal(Resource.memory, memoryLoad.get()) && - closeToIdeal(Resource.disk, diskLoad.get()) && - similarCost(bestAllocation.get().cost(), currentAllocation.cost())) { - return Optional.empty(); // Avoid small, unnecessary changes - } + if (similar(bestAllocation.get(), currentAllocation)) return Optional.empty(); return bestAllocation; } @@ -107,12 +101,16 @@ public class Autoscaler { return bestAllocation; } - private boolean similarCost(double cost1, double cost2) { - return similar(cost1, cost2, costDifferenceRatioWorthReallocation); - } - - private boolean closeToIdeal(Resource resource, double value) { - return similar(resource.idealAverageLoad(), value, idealDivergenceWorthReallocation); + /** Returns true if both total real resources and total cost are similar */ + private boolean similar(AllocatableClusterResources a, AllocatableClusterResources b) { + return similar(a.cost(), b.cost(), costDifferenceWorthReallocation) && + similar(a.realResources().vcpu() * a.nodes(), + b.realResources().vcpu() * b.nodes(), resourceDifferenceWorthReallocation) && + similar(a.realResources().memoryGb() * a.nodes(), + b.realResources().memoryGb() * b.nodes(), resourceDifferenceWorthReallocation) && + similar(a.realResources().diskGb() * a.nodes(), + b.realResources().diskGb() * b.nodes(), + resourceDifferenceWorthReallocation); } private boolean similar(double r1, double r2, double threshold) { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java index 3bb0676da4f..8bfb17c0bd4 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java @@ -99,16 +99,17 @@ public class AutoscalingTest { @Test public void testAutoscalingRespectsUpperLimit() { - NodeResources resources = new NodeResources(3, 100, 100, 1); + NodeResources hostResources = new NodeResources(3, 100, 100, 1); ClusterResources min = new ClusterResources( 2, 1, new NodeResources(1, 1, 1, 1)); ClusterResources max = new ClusterResources( 6, 1, new NodeResources(2.4, 78, 79, 1)); - AutoscalingTester tester = new AutoscalingTester(resources); + AutoscalingTester tester = new AutoscalingTester(hostResources); ApplicationId application1 = tester.applicationId("application1"); ClusterSpec cluster1 = tester.clusterSpec(ClusterSpec.Type.container, "cluster1"); // deploy - tester.deploy(application1, cluster1, 5, 1, resources); + tester.deploy(application1, cluster1, 5, 1, + new NodeResources(1.9, 70, 70, 1)); tester.addMeasurements(Resource.cpu, 0.25f, 120, application1); tester.addMeasurements(Resource.memory, 0.95f, 120, application1); tester.addMeasurements(Resource.disk, 0.95f, 120, application1); |