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();
}
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();
}
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();
}
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();
}
Aggregations