Search in sources :

Example 1 with LatencyCorrelation

use of com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation in project rest.li by linkedin.

the class TestLoadBalancerPerformanceSimulation method buildDefaultRelativeRunnerWithLinearLatency.

private LoadBalancerStrategyTestRunner buildDefaultRelativeRunnerWithLinearLatency(int numHosts, double badHostLinearFactor, double normalHostLinearFactor, double relativeLatencyHighThresholdFactor, double relativeLatencyLowThresholdFactor, int requestCountPerInterval) {
    List<LatencyCorrelation> latencyCorrelationList = new ArrayList<>();
    latencyCorrelationList.add((requestsPerInterval, intervalIndex) -> HEALTHY_LATENCY + (long) (badHostLinearFactor * requestsPerInterval));
    for (int i = 0; i < numHosts - 1; i++) {
        latencyCorrelationList.add((requestsPerInterval, intervalIndex) -> HEALTHY_LATENCY + (long) (normalHostLinearFactor * requestsPerInterval));
    }
    D2RelativeStrategyProperties relativeStrategyProperties = new D2RelativeStrategyProperties().setRelativeLatencyHighThresholdFactor(relativeLatencyHighThresholdFactor).setRelativeLatencyLowThresholdFactor(relativeLatencyLowThresholdFactor);
    return new LoadBalancerStrategyTestRunnerBuilder(loadBalancerStrategyType.RELATIVE, DEFAULT_SERVICE_NAME, numHosts).setConstantRequestCount(requestCountPerInterval).setNumIntervals(100).setDynamicLatency(latencyCorrelationList).setRelativeLoadBalancerStrategies(relativeStrategyProperties).build();
}
Also used : LatencyCorrelation(com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation) LoadBalancerStrategyTestRunnerBuilder(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder) ArrayList(java.util.ArrayList) D2RelativeStrategyProperties(com.linkedin.d2.D2RelativeStrategyProperties)

Example 2 with LatencyCorrelation

use of com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation in project rest.li by linkedin.

the class TestLoadBalancerPerformanceSimulation method buildRelativeRunnerWithRandomLatencyInRange.

private LoadBalancerStrategyTestRunner buildRelativeRunnerWithRandomLatencyInRange(boolean isFastRecovery, long badHostBaseLatency, long regularBaseLatency) {
    int numHosts = 20;
    int numRequestsPerInterval = 20;
    List<LatencyCorrelation> latencyCorrelationList = new ArrayList<>();
    long leftLimit = 0L;
    long rightLimit = 400L;
    latencyCorrelationList.add((requestsPerInterval, intervalIndex) -> badHostBaseLatency + (long) (Math.random() * (rightLimit - leftLimit)));
    for (int i = 1; i < numHosts; i++) {
        latencyCorrelationList.add((requestsPerInterval, intervalIndex) -> regularBaseLatency + (long) (Math.random() * (rightLimit - leftLimit)));
    }
    D2RelativeStrategyProperties relativeStrategyProperties = new D2RelativeStrategyProperties().setEnableFastRecovery(isFastRecovery);
    return new LoadBalancerStrategyTestRunnerBuilder(loadBalancerStrategyType.RELATIVE, DEFAULT_SERVICE_NAME, numHosts).setConstantRequestCount(numRequestsPerInterval).setNumIntervals(200).setDynamicLatency(latencyCorrelationList).setRelativeLoadBalancerStrategies(relativeStrategyProperties).build();
}
Also used : LatencyCorrelation(com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation) LoadBalancerStrategyTestRunnerBuilder(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder) ArrayList(java.util.ArrayList) D2RelativeStrategyProperties(com.linkedin.d2.D2RelativeStrategyProperties)

Example 3 with LatencyCorrelation

use of com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation in project rest.li by linkedin.

the class TestLoadBalancerPerformanceSimulation method buildRelativeRunnerWithDifferentLatency.

private LoadBalancerStrategyTestRunner buildRelativeRunnerWithDifferentLatency(double relativeLatencyHighThresholdFactor) {
    int minBaseLatency = 100;
    int baseLatencyDiff = 20;
    int numHosts = 10;
    double hostLinearFactor = 0.05;
    List<LatencyCorrelation> latencyCorrelationList = new ArrayList<>();
    for (int i = 0; i < numHosts; i++) {
        long baseLatency = i * baseLatencyDiff + minBaseLatency;
        latencyCorrelationList.add((requestsPerInterval, intervalIndex) -> baseLatency + (long) (hostLinearFactor * requestsPerInterval));
    }
    D2RelativeStrategyProperties relativeStrategyProperties = new D2RelativeStrategyProperties().setRelativeLatencyHighThresholdFactor(relativeLatencyHighThresholdFactor);
    return new LoadBalancerStrategyTestRunnerBuilder(loadBalancerStrategyType.RELATIVE, DEFAULT_SERVICE_NAME, numHosts).setConstantRequestCount(10000).setNumIntervals(100).setDynamicLatency(latencyCorrelationList).setRelativeLoadBalancerStrategies(relativeStrategyProperties).build();
}
Also used : LatencyCorrelation(com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation) LoadBalancerStrategyTestRunnerBuilder(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder) ArrayList(java.util.ArrayList) D2RelativeStrategyProperties(com.linkedin.d2.D2RelativeStrategyProperties)

Example 4 with LatencyCorrelation

use of com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation in project rest.li by linkedin.

the class TestLoadBalancerPerformanceSimulation method buildDefaultRunnerWithRecoveringBadHost.

private LoadBalancerStrategyTestRunner buildDefaultRunnerWithRecoveringBadHost(int numHosts, LatencyCorrelation recoveringHostLatencyCorrelation, double relativeLatencyLowThresholdFactor) {
    List<LatencyCorrelation> latencyCorrelationList = new ArrayList<>();
    latencyCorrelationList.add(recoveringHostLatencyCorrelation);
    for (int i = 0; i < numHosts - 1; i++) {
        latencyCorrelationList.add(HEALTHY_HOST_LATENCY_CORRELATION);
    }
    D2RelativeStrategyProperties relativeStrategyProperties = new D2RelativeStrategyProperties().setRelativeLatencyLowThresholdFactor(relativeLatencyLowThresholdFactor).setRelativeLatencyHighThresholdFactor(1.5);
    return new LoadBalancerStrategyTestRunnerBuilder(loadBalancerStrategyType.RELATIVE, DEFAULT_SERVICE_NAME, numHosts).setConstantRequestCount(DEFAULT_REQUESTS_PER_INTERVAL).setNumIntervals(200).setDynamicLatency(latencyCorrelationList).setRelativeLoadBalancerStrategies(relativeStrategyProperties).build();
}
Also used : LatencyCorrelation(com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation) LoadBalancerStrategyTestRunnerBuilder(com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder) ArrayList(java.util.ArrayList) D2RelativeStrategyProperties(com.linkedin.d2.D2RelativeStrategyProperties)

Aggregations

D2RelativeStrategyProperties (com.linkedin.d2.D2RelativeStrategyProperties)4 LatencyCorrelation (com.linkedin.d2.balancer.strategies.framework.LatencyCorrelation)4 LoadBalancerStrategyTestRunnerBuilder (com.linkedin.d2.balancer.strategies.framework.LoadBalancerStrategyTestRunnerBuilder)4 ArrayList (java.util.ArrayList)4