---
title: "How we use formal modeling, lightweight simulations, and chaos testing to design reliable distributed systems"
description: "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."
url: "https://swe.quest/articles/how-we-use-formal-modeling-lightweight-simulations-and-chaos-testing-to-design-aca03cf9b6abf48d"
canonical: "https://www.datadoghq.com/blog/engineering/formal-modeling-and-simulation/"
source: "Datadog Engineering"
published: "2024-11-20"
difficulty: "hard"
kind: "Case study"
reading_minutes: 23
tags: ["formal-methods","messaging","distributed-systems","chaos-engineering","multi-tenancy"]
---

# How we use formal modeling, lightweight simulations, and chaos testing to design reliable distributed systems

A post on [Datadog Engineering](https://swe.quest/sources/datadog.md), published 2024-11-20, 23 min read, Case study. Original: [https://www.datadoghq.com/blog/engineering/formal-modeling-and-simulation/](https://www.datadoghq.com/blog/engineering/formal-modeling-and-simulation/)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Formal methods](https://swe.quest/tags/formal-methods.md) (Architecture & design)
- [Queues & messaging](https://swe.quest/tags/messaging.md) (Backend & APIs)
- [Distributed systems](https://swe.quest/tags/distributed-systems.md) (Distributed systems)
- [Chaos engineering](https://swe.quest/tags/chaos-engineering.md) (Reliability & operations)
- [Multi-tenancy](https://swe.quest/tags/multi-tenancy.md) (Architecture & design)

## Prerequisites

- TLA+ basics ([easy posts on Formal methods](https://swe.quest/tags/formal-methods.md?difficulty=easy))
- message queue semantics ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))
- distributed systems failure modes ([easy posts on Distributed systems](https://swe.quest/tags/distributed-systems.md?difficulty=easy))

## Keywords

TLA+, TLC, Courier, FoundationDB, gRPC, Datadog

## Related posts

- [Protocol-Aware Deterministic Simulation Testing](https://swe.quest/articles/protocol-aware-deterministic-simulation-testing-7f3b613be8faf2a6.md): TigerBeetle · 2026-08-20 · Hard · 10 min read · Formal methods, Testing, Consensus, Replication, Storage engines
  TigerBeetle'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.
- [A Descent Into the Vörtex](https://swe.quest/articles/a-descent-into-the-vortex-6dcd52020263ac13.md): TigerBeetle · 2025-02-13 · Medium · 3 min read · Testing, Chaos engineering, Distributed databases, Zig
  TigerBeetle 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.
- [Simulation Testing For Liveness](https://swe.quest/articles/simulation-testing-for-liveness-7a5ba398eed57d56.md): TigerBeetle · 2023-07-06 · Hard · 4 min read · Formal methods, Testing, Consensus, Distributed systems, Resilience
  TigerBeetle'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.
- [BellJar: A new framework for testing system recoverability at scale](https://swe.quest/articles/belljar-a-new-framework-for-testing-system-recoverability-at-scale-7811c5029ecc4a97.md): Meta Engineering · 2022-05-05 · Medium · 15 min read · Chaos engineering, Resilience, Testing, SRE, Distributed systems
  BellJar is Meta's framework for proving that infrastructure services can recover from a total outage.
- [How we continuously validate formal specifications in production](https://swe.quest/articles/how-we-continuously-validate-formal-specifications-in-production-8af79b473bcc3ebf.md): Datadog Engineering · 2026-11-05 · Hard · 16 min read · Formal methods, Testing, Distributed systems, Rust, Observability
  FETCh (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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
