Free — no signup required

Introduction: Testing is Not Enough

2 min read

The Concurrency Trap

Imagine you are building a complex distributed system, like a cloud database. You write thousands of unit tests. They all pass. You run integration tests. They pass. You deploy it, and everything seems fine.

Two weeks later, at 3 AM on a Saturday, the entire system crashes, corrupting customer data. Why? Because two very specific events happened in the exact opposite order than you expected — a scenario your tests never covered.

The Limits of Testing

There is a famous computer science quote, attributed to Edsger Dijkstra: "Program testing can be used to show the presence of bugs, but never to show their absence."

Testing checks specific paths through your code that you thought to write down. In distributed systems, with multiple machines acting simultaneously, the number of possible execution paths is unimaginably large. Consider a simple system with just 3 concurrent processes, each performing 5 steps. The number of possible interleavings of those steps is over 75,000. Real distributed systems have hundreds of processes and thousands of steps. You cannot possibly test them all.

The problem is especially acute for race conditions — bugs that only appear when two events happen in a precise, unlikely order. These bugs may occur once in a billion executions in production, making them nearly impossible to reproduce in a test environment, yet catastrophic when they do occur.

Enter Formal Verification

Formal Verification is a fundamentally different approach. Instead of writing code and hoping it works, you use mathematical techniques to prove that your system design is correct, regardless of what order events happen in.

Think of it this way: testing is like driving a car around the block to see if the brakes work. Formal verification is like having a structural engineer calculate, using physics and materials science, exactly how much force the brakes can withstand before failing — covering every possible scenario, not just the ones you thought to test.

In this topic, we will examine TLA+, a specification language used by engineers at Amazon Web Services, Microsoft, and Intel to design their most critical distributed systems. Amazon's engineers have used TLA+ to find subtle bugs in DynamoDB, S3, and EBS — bugs that would have been nearly impossible to discover through testing alone.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free