AI summary by TwinMind

The Two Generals’ Problem

Tom Scott

8m 26s

Personal Food Delivery Experience (September 2018)

  • Author exhausted, ordered pizza via UK food delivery app
  • Payment appeared successful (Apple Pay tick) but app showed "failed" message
  • Checked order history - order was processing despite failure message
  • Decided not to reorder based on computer science knowledge
  • Food arrived successfully after 30 minutes

The Two Generals Problem - Computer Science Theory

  • Classic computer science problem involving coordination
  • Setup: Two armies on opposite sides of valley, heavily fortified castle in middle
  • Victory requires simultaneous attack from both sides
  • Communication only via messengers through dangerous valley
  • Core challenge: How to coordinate attack timing with unreliable communication

The Unsolvable Nature

  • General A sends proposed attack time (8 o'clock) to General B
  • Messenger might not survive valley crossing
  • If General B receives message, must send acknowledgement back
  • Acknowledgement messenger might also not survive
  • Creates infinite loop of acknowledgements needing acknowledgements
  • Problem is mathematically unsolvable under strict rules
  • No guarantee of certainty in message delivery/receipt

Real-World Application - Food Delivery Bug

  • Widespread issue across UK affecting multiple customers
  • Customers as "General A", app servers as "General B"
  • Payment processing succeeded but confirmation messages failed
  • Customers repeatedly hit "try again" button
  • Results varied:
    • Some restaurants sent single order despite multiple payments
    • Some sent multiple identical orders (2-3 deliveries)
    • Some customers received no food at all
  • Customer service lines overwhelmed
  • Multiple poor engineering decisions over time, not single engineer fault

Solution - Idempotency Tokens

  • Real-world solution to Two Generals Problem
  • Unique value generated per transaction (shopping cart ID)
  • Sent with each order request
  • Server stores idempotency key to track requests
  • Duplicate requests with same key ignored
  • Server resends original acknowledgement instead of processing again
  • Ensures operations happen only once despite multiple requests
  • Applicable beyond shopping: log deletion, text messages, any one-time operations

Additional Safeguards

  • Duplicate order prevention: Block identical orders on same credit card for same restaurant within minutes
  • Human oversight for complete connection failures
  • Idempotence principle: Multiple identical requests = single execution

Dashlane Sponsorship Segment

  • Password manager sponsoring "The Basics" series
  • Master password never transmitted over internet
  • Local encryption using master password only user knows
  • Encrypted bundles sent to Dashlane servers (appear as random noise)
  • Servers synchronize encrypted data between devices
  • Only user devices can decrypt with master password
  • Additional per-device keys for extra security
  • Data breach wouldn't compromise user passwords (random noise only)
  • Single password to remember vs. reusing weak passwords
  • Offer: dashlane.com/tomscott for 30-day free trial, code "tomscott" for 10% off

TwinMind

Get summaries like this for your own meetings

TwinMind takes notes in the background during meetings, lectures, and calls, then writes the summary for you.

Free plan to get started

No bot joins your calls

Phone, desktop & Chrome apps

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome