← Lessons

quiz vs the machine

Gold1400

System Design

The Two Generals Problem

Why two parties can never be certain of agreement over an unreliable channel.

4 min read · core · beat Gold to climb

The story

Two generals must attack a city at the same time to win, but they can only communicate by messengers who might be captured. General A sends attack at dawn. To be sure it arrived, A wants an acknowledgment. But B cannot know the ack arrived without an ack of the ack, and so on forever.

The impossibility

No finite number of messages can give both sides certainty that they agree, because the last message is always unconfirmed. This is the two generals problem, and it proves that guaranteed agreement is impossible over an unreliable channel.

What it means in practice

You cannot achieve perfect certainty, so real systems settle for high probability. Retransmit until an ack arrives, and accept a tiny chance of mismatch. The famous TCP handshake lives with this, never truly proving the final ack landed.

The takeaway

Distributed agreement over a lossy link is fundamentally about managing uncertainty, not eliminating it. Designs lean on retries, timeouts, and idempotency rather than impossible guarantees.

Key idea

The two generals problem shows that two parties cannot reach guaranteed agreement over an unreliable channel because the final acknowledgment is never confirmed.

Check yourself

Answer to earn rating on the learn ladder.

1. Why can the two generals never be certain they agree?

2. What do real systems do given this impossibility?