Skip to content
← Writing

The Byzantine Generals Problem, played live

· 2 min read

At a DevCongress meetup at the Fido hub, our system design instructor, Tonny-Bright Sogli, ran a live simulation of the Byzantine Generals Problem.

We split into groups of about five, and each group played a general. A game master gave an order, attack or retreat, and the goal was for every general to end up acting on the same order. We played three rounds.

Round 1

A loyal leader passed the game master's order down the chain. Every group relayed it as they received it, and everyone agreed.

Round 2

One group in the chain was compromised. It deliberately sent different orders to different generals. The groups after it had no way of telling which version was real.

Round 3

Every group sent conflicting messages to every other group. Nobody could tell what was true.

We kept talking after the third round and went through other scenarios, mostly around one question: how many loyal generals do you need so that a majority vote still beats the liars, even when the traitors coordinate perfectly against you?

n ≥ 3f + 1

Lamport, Shostak and Pease answered this in 1982. With n generals, f traitors, and messages that can be forged, the loyal generals can only be guaranteed to agree when n ≥ 3f + 1.

  • 1 traitor needs at least 4 generals
  • 2 traitors need at least 7
  • 3 traitors need at least 10

Below that, agreement isn't just unlikely. It's impossible, however clever the protocol is. You can try different numbers here:

Generals
4
Traitors
1

Consensus guaranteed

4 ≥ 3 × 1 + 1. The loyal generals agree no matter what the traitors say.

Blue generals are loyal, red ones lie. Dashed lines are messages that can't be trusted.

Why three and not two

The smallest case helped me see it. Take a commander and two lieutenants, A and B, where one of the three is a traitor. A hears "attack" from the commander, and B tells A that the commander said "retreat".

Either the commander is the traitor and gave them different orders, or B is the traitor and is lying. A receives exactly the same messages in both cases, but the right response is different in each, so there's no rule A can follow that works both times. The paper extends this to bigger numbers by treating each of the three as a group of f generals.

Another way to see why 3f + 1 is enough: out of 3f + 1 generals, any two groups of 2f + 1 share at least f + 1 members. At least one of those is loyal, and a loyal general won't tell the two groups different things. Practical protocols like PBFT are built on that overlap.

What I read afterwards

  • Systems that only expect crashes need fewer machines. Raft and Paxos, used by etcd, Consul and CockroachDB, tolerate f failures with 2f + 1 nodes, because they assume a failed node stops responding rather than lying. For servers you run yourself, that's usually a fair assumption.
  • Signed messages change the result. If a lieutenant can't forge the commander's signature, the paper shows the loyal generals can agree with any number of traitors.
  • Byzantine fault tolerance shows up where you can't trust every participant: blockchains and distributed ledgers, aircraft and spacecraft where redundant flight computers vote on readings, and zero-trust architectures.

The original paper is short and readable: The Byzantine Generals Problem by Leslie Lamport, Robert Shostak and Marshall Pease (1982).

Thanks to Tonny-Bright and DevCongress for running the session.

07 · Contact

Write to me.

I'm open to software engineering and data roles, and to freelance work. If you have a process that still runs on copy and paste, I'd like to hear about it.