Skip to content

Checks: observability and recovery

Templates for the four observability and recovery stories. These run against a test environment with load, a real orchestrator or a real alerting pipeline, so they belong in a scheduled resilience suite rather than in every commit.

C-21: scaling out doesn’t reduce completions

Section titled “C-21: scaling out doesn’t reduce completions”
  • Proves: under the same overload, adding workers never lowers completed jobs per second, and downstream attempts stay bounded.
  • Fails for: scaling on queue depth with unbounded downstream concurrency. The autoscaler that made the backlog worse.
  • Harness needs: a load generator; a downstream stub that slows down beyond a concurrency limit; metrics for completions and downstream attempts.
@Test
void moreWorkersNeverMeanFewerCompletions() {
downstreamStub.saturatesAbove(100, 200); // 100 in flight, 200 calls/s
var load = loadGenerator.constant(250, Duration.ofMinutes(10));
var tenWorkers = runWith(10, load);
var fortyWorkers = runWith(40, load);
assertThat(fortyWorkers.completedPerSecond()).isGreaterThanOrEqualTo(tenWorkers.completedPerSecond() * 0.95);
assertThat(fortyWorkers.downstreamAttemptsPerSecond()).isLessThanOrEqualTo(200 * 1.10);
}

C-22: the journey alerts, not just the endpoint

Section titled “C-22: the journey alerts, not just the endpoint”
  • Proves: with the fulfillment worker stopped, the report counts accepted orders past their deadline and an alert fires within minutes, while the API’s availability stays at 100%.
  • Fails for: endpoint-only objectives. The healthy dashboard for a broken customer journey.
  • Harness needs: stop a worker; a controllable clock or a short deadline in test; read the alert pipeline.
@Test
void aStoppedWorkerRaisesAJourneyAlertWhileTheApiStaysGreen() {
fulfillmentWorker.stop();
var start = clock.now();
for (int i = 0; i < 30; i++) { checkout.placeOrder(sampleOrder(i)); clock.advance(Duration.ofSeconds(20)); }
var report = slo.report("orders-reach-warehouse-within-5m", start, clock.now());
var firstAlert = alerts.firstSince(start, "orders-reach-warehouse");
assertThat(report.breached()).isGreaterThan(0);
assertThat(firstAlert).isPresent();
assertThat(Duration.between(start, firstAlert.get().firedAt())).isLessThanOrEqualTo(Duration.ofMinutes(7));
assertThat(slo.report("checkout-availability", start, clock.now()).ratio()).isEqualTo(1.0);
}

The last assertion is deliberate. It documents why the endpoint objective can’t be the only one.

C-23: slow starts survive; stuck processes don’t

Section titled “C-23: slow starts survive; stuck processes don’t”
  • Proves: an instance that takes 90 seconds to build its index becomes ready without being restarted, and an instance that stops making progress is restarted.
  • Fails for: one liveness probe that means ready. The self-healing restart that prevented recovery.
  • Harness needs: a test cluster; a test image that can simulate a slow start and a hang.
@Test
void aSlowButProgressingInstanceBecomesReadyWithoutRestarts() {
var pod = cluster.deploy(searchService().withEnv("SIMULATE_INDEX_BUILD_SECONDS", "90"));
cluster.awaitReady(pod, Duration.ofMinutes(4));
assertThat(cluster.restartCount(pod)).isZero();
assertThat(cluster.firstTrafficAt(pod)).isAfter(cluster.readyAt(pod).minusSeconds(1));
}
@Test
void aStuckInstanceIsStillRestarted() {
var pod = cluster.deploy(searchService().withEnv("SIMULATE_HANG_AFTER_SECONDS", "30"));
await().atMost(Duration.ofMinutes(4)).until(() -> cluster.restartCount(pod) >= 1);
}

Add a third check that tracks the margin: fail the build when measured start-up time exceeds 60% of the startup probe’s allowance, so the next year’s growth shows up as a failing test instead of an outage.

  • Proves: a canary that fails every request from one small cohort fails the gate and names the cohort, and a cohort with too little traffic is reported as insufficient observations, not as a pass.
  • Fails for: a global success-rate gate. The green canary that failed a small tenant.
  • Harness needs: feed the gate a recorded canary window, grouped by cohort.
@Test
void oneFailingCohortFailsTheCanaryEvenWhenTheAggregatePasses() {
var window = CanaryWindow.builder()
.cohort("all-others", canary(19_989, 10), baseline(379_791, 190))
.cohort("legacy-numbering", canary(8, 8), baseline(152, 0))
.cohort("tenant-T-201", canary(3, 0), baseline(57, 0))
.build();
var verdict = canaryGate.evaluate(window);
assertThat(window.aggregateSuccessRate()).isGreaterThan(0.999); // the trap
assertThat(verdict.passed()).isFalse();
assertThat(verdict.failedCohorts()).extracting(CohortResult::name).containsExactly("legacy-numbering");
assertThat(verdict.cohort("legacy-numbering"))
.extracting(CohortResult::failures, CohortResult::requests).containsExactly(8L, 8L);
assertThat(verdict.cohort("tenant-T-201").outcome()).isEqualTo(INSUFFICIENT_OBSERVATIONS);
}

The numbers are the story’s canary hour: 20,000 canary requests with 18 failures, a 99.91% success rate.

Written and edited by Abhinav Taduka, enterprise software architect.