use of com.linkedin.d2.backuprequests.GaussianResponseTimeDistribution in project rest.li by linkedin.
the class TestBoundedCostBackupRequestsStrategy method testMinBackupDelay.
@Test
public void testMinBackupDelay() {
BoundedCostBackupRequestsStrategy strategy = new BoundedCostBackupRequestsStrategy(5, 64, 1024, 128, 100);
BackupRequestsSimulator simulator = new BackupRequestsSimulator(new PoissonEventsArrival(200, TimeUnit.SECONDS), new GaussianResponseTimeDistribution(10, 50, 10, 99, TimeUnit.MILLISECONDS), strategy);
simulator.simulate(ITERATIONS);
assertEquals(simulator.getNumberOfBackupRequestsMade(), 0);
}
use of com.linkedin.d2.backuprequests.GaussianResponseTimeDistribution in project rest.li by linkedin.
the class TestBoundedCostBackupRequestsStrategy method testLongTailEffectOfBackupRequests.
@Test
public void testLongTailEffectOfBackupRequests() {
BoundedCostBackupRequestsStrategy strategy = new BoundedCostBackupRequestsStrategy(5, 64, 1024, 128, 0);
ResponseTimeDistribution hiccupDistribution = new GaussianResponseTimeDistribution(500, 1000, 500, TimeUnit.MILLISECONDS);
BackupRequestsSimulator simulator = new BackupRequestsSimulator(new PoissonEventsArrival(200, TimeUnit.SECONDS), new GaussianWithHiccupResponseTimeDistribution(2, 10, 5, TimeUnit.MILLISECONDS, hiccupDistribution, 0.02), strategy);
simulator.simulate(ITERATIONS);
double withoutBackup99 = simulator.getResponseTimeWithoutBackupRequestsHistogram().getValueAtPercentile(99);
double withBackup99 = simulator.getResponseTimeWithBackupRequestsHistogram().getValueAtPercentile(99);
assertTrue(withBackup99 * 10 < withoutBackup99, "99th percentile is expected to be improved 10x, with backup: " + withBackup99 / 1000000 + "ms, without backup: " + withoutBackup99 / 1000000 + "ms");
}
use of com.linkedin.d2.backuprequests.GaussianResponseTimeDistribution in project rest.li by linkedin.
the class TestBoundedCostBackupRequestsStrategy method testNumberOfBackupRequestsMade.
public double testNumberOfBackupRequestsMade(int pct, int burstSize) {
BoundedCostBackupRequestsStrategy strategy = new BoundedCostBackupRequestsStrategy(pct, burstSize, 1024, 128, 0);
BackupRequestsSimulator simulator = new BackupRequestsSimulator(new PoissonEventsArrival(200, TimeUnit.SECONDS), new GaussianResponseTimeDistribution(20, 100, 50, TimeUnit.MILLISECONDS), strategy);
simulator.simulate(ITERATIONS);
return ((100d * simulator.getNumberOfBackupRequestsMade()) / ITERATIONS);
}
use of com.linkedin.d2.backuprequests.GaussianResponseTimeDistribution in project rest.li by linkedin.
the class TestBoundedCostBackupRequestsStrategy method testValuesOutOfRange.
@Test
public void testValuesOutOfRange() {
BoundedCostBackupRequestsStrategy strategy = new BoundedCostBackupRequestsStrategy(5, 64, 1024, 128, 0);
BackupRequestsSimulator simulator = new BackupRequestsSimulator(new PoissonEventsArrival(200, TimeUnit.SECONDS), new GaussianResponseTimeDistribution(BoundedCostBackupRequestsStrategy.HIGH, 2 * BoundedCostBackupRequestsStrategy.HIGH, BoundedCostBackupRequestsStrategy.HIGH, TimeUnit.NANOSECONDS), strategy);
simulator.simulate(ITERATIONS);
assertTrue(((100d * simulator.getNumberOfBackupRequestsMade()) / ITERATIONS) < 5 + EXPECTED_PRECISSION);
assertTrue(strategy.getTimeUntilBackupRequestNano().get() >= BoundedCostBackupRequestsStrategy.HIGH);
}
use of com.linkedin.d2.backuprequests.GaussianResponseTimeDistribution in project rest.li by linkedin.
the class TestBackupRequestsClient method createClient.
private BackupRequestsClient createClient(Supplier<ServiceProperties> servicePropertiesSupplier, TestBackupRequestsStrategyStatsConsumer statsConsumer, boolean isD2Async) {
ResponseTimeDistribution hiccupDistribution = new GaussianResponseTimeDistribution(500, 1000, 500, TimeUnit.MILLISECONDS);
ResponseTimeDistribution responseTime = new GaussianWithHiccupResponseTimeDistribution(2, 10, 5, TimeUnit.MILLISECONDS, hiccupDistribution, 0.02);
return createClient(servicePropertiesSupplier, statsConsumer, responseTime, isD2Async);
}
Aggregations