Search in sources :

Example 1 with ClutchConfiguration

use of com.netflix.control.clutch.ClutchConfiguration in project mantis by Netflix.

the class RpsClutchConfigurationSelectorTest method testSetPointQuantile.

@Test
public void testSetPointQuantile() {
    UpdateDoublesSketch rpsSketch = UpdateDoublesSketch.builder().setK(1024).build();
    for (int i = 1; i <= 100; i++) {
        rpsSketch.update(i);
    }
    Map<Clutch.Metric, UpdateDoublesSketch> sketches = ImmutableMap.of(Clutch.Metric.RPS, rpsSketch);
    StageScalingPolicy scalingPolicy = new StageScalingPolicy(1, 2, 9, 0, 0, 400L, null);
    StageSchedulingInfo schedulingInfo = StageSchedulingInfo.builder().numberOfInstances(3).scalingPolicy(scalingPolicy).scalable(true).build();
    RpsClutchConfigurationSelector selector = new RpsClutchConfigurationSelector(1, schedulingInfo, null);
    ClutchConfiguration config = selector.apply(sketches);
    assertEquals(76.0, config.getSetPoint(), 1e-10);
    assertEquals(Tuple.of(22.8, 0.0), config.getRope());
}
Also used : StageScalingPolicy(io.mantisrx.runtime.descriptor.StageScalingPolicy) UpdateDoublesSketch(com.yahoo.sketches.quantiles.UpdateDoublesSketch) StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) ClutchConfiguration(com.netflix.control.clutch.ClutchConfiguration) Test(org.junit.Test)

Example 2 with ClutchConfiguration

use of com.netflix.control.clutch.ClutchConfiguration in project mantis by Netflix.

the class RpsClutchConfigurationSelector method apply.

@Override
public ClutchConfiguration apply(Map<Clutch.Metric, UpdateDoublesSketch> sketches) {
    double setPoint = getSetpoint(sketches);
    Tuple2<Double, Double> rope = getRope().map(x -> x / 100.0 * setPoint, y -> y / 100.0 * setPoint);
    // Gain - number of ticks within the cooldown period. This is the minimum number of times PID output will accumulate
    // before an action is taken.
    long deltaT = getCooldownSecs() / 30l;
    double kp = 1.0 / setPoint / getCumulativeIntegralDivisor(getIntegralScaler(), deltaT);
    double ki = 0.0;
    double kd = 1.0 / setPoint / getCumulativeIntegralDivisor(getIntegralScaler(), deltaT);
    ClutchConfiguration config = com.netflix.control.clutch.ClutchConfiguration.builder().metric(Clutch.Metric.RPS).setPoint(setPoint).kp(kp).ki(ki).kd(kd).integralDecay(getIntegralScaler()).minSize(getMinSize()).maxSize(getMaxSize()).rope(rope).cooldownInterval(getCooldownSecs()).cooldownUnits(TimeUnit.SECONDS).build();
    // If config is similar to previous, don't return a new config which would trigger a PID reset.
    if (isSimilarToPreviousConfig(config)) {
        return prevConfig;
    }
    prevConfig = config;
    return config;
}
Also used : ClutchConfiguration(com.netflix.control.clutch.ClutchConfiguration)

Example 3 with ClutchConfiguration

use of com.netflix.control.clutch.ClutchConfiguration in project mantis by Netflix.

the class RpsClutchConfigurationSelectorTest method testApply.

@Test
public void testApply() {
    UpdateDoublesSketch rpsSketch = UpdateDoublesSketch.builder().setK(1024).build();
    rpsSketch.update(100);
    Map<Clutch.Metric, UpdateDoublesSketch> sketches = ImmutableMap.of(Clutch.Metric.RPS, rpsSketch);
    ClutchRpsPIDConfig rpsConfig = new ClutchRpsPIDConfig(0.0, Tuple.of(20.0, 10.0), 0, 0, Option.none(), Option.none(), Option.none(), Option.none(), Option.none());
    io.mantisrx.server.worker.jobmaster.clutch.ClutchConfiguration customConfig = new io.mantisrx.server.worker.jobmaster.clutch.ClutchConfiguration(1, 10, 0, Option.none(), Option.of(300L), Option.none(), Option.none(), Option.none(), Option.none(), Option.none(), Option.of(rpsConfig), Option.none(), Option.of(0.7));
    StageSchedulingInfo schedulingInfo = StageSchedulingInfo.builder().numberOfInstances(3).machineDefinition(null).scalable(true).build();
    RpsClutchConfigurationSelector selector = new RpsClutchConfigurationSelector(1, schedulingInfo, customConfig);
    ClutchConfiguration config = selector.apply(sketches);
    assertEquals(Clutch.Metric.RPS, config.getMetric());
    assertEquals(100.0, config.getSetPoint(), 1e-10);
    assertEquals(1, config.getMinSize());
    assertEquals(10, config.getMaxSize());
    assertEquals(Tuple.of(20.0, 10.0), config.getRope());
    assertEquals(300L, config.getCooldownInterval());
    assertEquals(0.3, config.getIntegralDecay(), 1e-10);
}
Also used : UpdateDoublesSketch(com.yahoo.sketches.quantiles.UpdateDoublesSketch) ClutchConfiguration(com.netflix.control.clutch.ClutchConfiguration) StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) Test(org.junit.Test)

Example 4 with ClutchConfiguration

use of com.netflix.control.clutch.ClutchConfiguration in project mantis by Netflix.

the class RpsClutchConfigurationSelectorTest method testScalingPolicyFallback.

@Test
public void testScalingPolicyFallback() {
    UpdateDoublesSketch rpsSketch = UpdateDoublesSketch.builder().setK(1024).build();
    rpsSketch.update(100);
    Map<Clutch.Metric, UpdateDoublesSketch> sketches = ImmutableMap.of(Clutch.Metric.RPS, rpsSketch);
    StageScalingPolicy scalingPolicy = new StageScalingPolicy(1, 2, 9, 0, 0, 400L, null);
    StageSchedulingInfo schedulingInfo = StageSchedulingInfo.builder().numberOfInstances(3).scalingPolicy(scalingPolicy).scalable(true).build();
    RpsClutchConfigurationSelector selector = new RpsClutchConfigurationSelector(1, schedulingInfo, null);
    ClutchConfiguration config = selector.apply(sketches);
    assertEquals(Clutch.Metric.RPS, config.getMetric());
    assertEquals(100.0, config.getSetPoint(), 1e-10);
    assertEquals(2, config.getMinSize());
    assertEquals(9, config.getMaxSize());
    assertEquals(Tuple.of(30.0, 0.0), config.getRope());
    assertEquals(400L, config.getCooldownInterval());
    assertEquals(0.9, config.getIntegralDecay(), 1e-10);
}
Also used : StageScalingPolicy(io.mantisrx.runtime.descriptor.StageScalingPolicy) UpdateDoublesSketch(com.yahoo.sketches.quantiles.UpdateDoublesSketch) StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) ClutchConfiguration(com.netflix.control.clutch.ClutchConfiguration) Test(org.junit.Test)

Example 5 with ClutchConfiguration

use of com.netflix.control.clutch.ClutchConfiguration in project mantis by Netflix.

the class RpsScaleComputerTest method testDefaultConfig.

@Test
public void testDefaultConfig() {
    RpsScaleComputer scaleComputer = new RpsScaleComputer(null);
    ClutchConfiguration config = ClutchConfiguration.builder().minSize(1).maxSize(1000).build();
    double scale = scaleComputer.apply(config, 100L, 0.1);
    assertEquals(110, scale, 1e-10);
    scale = scaleComputer.apply(config, 100L, 0.5);
    assertEquals(150, scale, 1e-10);
    scale = scaleComputer.apply(config, 100L, -0.7);
    assertEquals(30, scale, 1e-10);
}
Also used : ClutchConfiguration(com.netflix.control.clutch.ClutchConfiguration) Test(org.junit.Test)

Aggregations

ClutchConfiguration (com.netflix.control.clutch.ClutchConfiguration)8 Test (org.junit.Test)7 UpdateDoublesSketch (com.yahoo.sketches.quantiles.UpdateDoublesSketch)5 StageSchedulingInfo (io.mantisrx.runtime.descriptor.StageSchedulingInfo)5 StageScalingPolicy (io.mantisrx.runtime.descriptor.StageScalingPolicy)4