Search in sources :

Example 1 with GaussianResponseTimeDistribution

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);
}
Also used : BoundedCostBackupRequestsStrategy(com.linkedin.d2.backuprequests.BoundedCostBackupRequestsStrategy) Test(org.testng.annotations.Test)

Example 2 with GaussianResponseTimeDistribution

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");
}
Also used : BoundedCostBackupRequestsStrategy(com.linkedin.d2.backuprequests.BoundedCostBackupRequestsStrategy) Test(org.testng.annotations.Test)

Example 3 with GaussianResponseTimeDistribution

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);
}
Also used : BoundedCostBackupRequestsStrategy(com.linkedin.d2.backuprequests.BoundedCostBackupRequestsStrategy)

Example 4 with GaussianResponseTimeDistribution

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);
}
Also used : BoundedCostBackupRequestsStrategy(com.linkedin.d2.backuprequests.BoundedCostBackupRequestsStrategy) Test(org.testng.annotations.Test)

Example 5 with GaussianResponseTimeDistribution

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);
}
Also used : GaussianWithHiccupResponseTimeDistribution(com.linkedin.d2.backuprequests.GaussianWithHiccupResponseTimeDistribution) GaussianWithHiccupResponseTimeDistribution(com.linkedin.d2.backuprequests.GaussianWithHiccupResponseTimeDistribution) ResponseTimeDistribution(com.linkedin.d2.backuprequests.ResponseTimeDistribution) ConstantResponseTimeDistribution(com.linkedin.d2.backuprequests.ConstantResponseTimeDistribution) GaussianResponseTimeDistribution(com.linkedin.d2.backuprequests.GaussianResponseTimeDistribution) GaussianResponseTimeDistribution(com.linkedin.d2.backuprequests.GaussianResponseTimeDistribution)

Aggregations

BoundedCostBackupRequestsStrategy (com.linkedin.d2.backuprequests.BoundedCostBackupRequestsStrategy)4 Test (org.testng.annotations.Test)3 ConstantResponseTimeDistribution (com.linkedin.d2.backuprequests.ConstantResponseTimeDistribution)1 GaussianResponseTimeDistribution (com.linkedin.d2.backuprequests.GaussianResponseTimeDistribution)1 GaussianWithHiccupResponseTimeDistribution (com.linkedin.d2.backuprequests.GaussianWithHiccupResponseTimeDistribution)1 ResponseTimeDistribution (com.linkedin.d2.backuprequests.ResponseTimeDistribution)1