How we use formal modeling, lightweight simulations, and chaos testing to design reliable distributed systems
Datadog validated the design of Courier, a multi-tenant message queue built on multiple FoundationDB clusters after its March 2023 outage, by combining TLA+ formal modeling, lightweight simulations and chaos testing. Each tenant is sharded across 4 of 8 FoundationDB clusters so that no two tenants share the same set, and brokers health-check clusters and route around failures. The TLA+ spec models brokers, senders and receivers with weak fairness, and TLC checks properties such as at-least-once delivery across every reachable state. Simulations then cover what model checking cannot, such as latency, cost and scalability. Together these give design-level confidence that unit tests miss, at the cost of keeping models and simulations in sync with the design.
Related posts
- Protocol-Aware Deterministic Simulation Testing
TigerBeetle hardMasterTigerBeetle's deterministic simulator (the VOPR) has full visibility into each replica's consensus and storage state, so it can check invariants that black-box tools like Jepsen or Antithesis cannot see through user-facing APIs. For safety, it asserts that every committed WAL entry has matching checksums across replicas, that LSM manifest structure is consistent everywhere, and that replicas are byte-for-byte identical, which goes deeper than the cheaper production checks that crash a diverging backup. For liveness, it enforces per-replica invariants: a replica with an uncorrupted WAL must never need cluster coordination to recover, and missing blocks must be repaired from intact copies on other replicas whenever any copy still exists.
- A Descent Into the Vörtex
TigerBeetle mediumAdeptTigerBeetle has added Vortex, a non-deterministic, generative full-system test harness that complements its Deterministic Simulation Testing by exercising real production binaries and client libraries from the outside in. A supervisor coordinates a cluster of stock replicas, a workload that checks safety properties, and language-specific client drivers (Zig and Java so far). It injects network faults through a TCP proxy, kills or pauses processes, and runs liveness checks. In four months it found two bugs: incorrect request batching in tb_client and double connection termination. Planned work includes continuous runs, upgrade testing, network partitions and storage faults.
- Simulation Testing For Liveness
TigerBeetle hardMasterTigerBeetle's VOPR simulator now has a "liveness" mode alongside its "safety" mode, because uniformly random, eventually-healing faults can never surface livelocks such as a permanently asymmetric partition that triggers endless view changes. After a period of random fault injection, the simulator picks a quorum as the core, restarts and heals everything inside it, makes all failures involving non-core replicas permanent, and then requires the core to process every transaction before a timeout. The new mode found a resonance bug in which parallel log repair combined with round-robin repair targets always sent each missing op to the one replica that also lacked it, a stall that previously cleared only when a restart reset the counter.
- BellJar: A new framework for testing system recoverability at scale
Meta Engineering mediumAdeptBellJar is Meta's framework for proving that infrastructure services can recover from a total outage. It builds ephemeral VM environments that are indistinguishable from production but have all network traffic blackholed by fault injection, loopback included. Operators then allowlist only the specific capabilities their recovery needs, such as DNS or a named storage cluster. Each test is written in a few lines of Python and combines the service, hardware, runbook steps, tooling, validation criteria and allowed dependencies into a Boolean recoverability check that can run in CI/CD. The tests also regenerate runbook documentation and expose hidden or circular dependencies. Combined across teams, they form a recovery graph that differs from the runtime graph seen in distributed tracing.
- How we continuously validate formal specifications in production
Datadog Engineering hardMasterFETCh (Formal Execution Trace Checker) compiles TLA+ specifications into Rust runtime monitors that consume production telemetry and flag any state transition the spec forbids, catching drift between a formal model and the evolving implementation. Datadog applied it to Husky's event routing system and found that a placement-logic change had let conflicting placements persist for about a year, which would have crashed backfill during placement data-loss recovery. TLA+ refinement lets an unbounded observable spec be monitored in production while a bounded refinement stays model-checkable. Lightweight typing via existential quantifiers and type annotations makes the specs translatable to code. Monitor state stays tractable by checking placements globally and checking per-event routing locally in sidecars.