The Two Generals’ Problem

Loading...
  • Published on: 12 August 2019
  • Time to tell a story about idempotency, computer science, and the Night of the Multiple Orders. • Sponsored by Dashlane —try 30 days for free at: https://www.dashlane.com/tomscott

    MORE BASICS: https://www.youtube.com/playlist?list=PL96C35uN7xGLLeET0dOWaKHkAlPsrkcha

    Written by Sean M Elliott and Tom Scott
    Directed by Tomek
    Graphics by Mooviemakers https://www.mooviemakers.co.uk/
    Audio mix by Haerther Productions https://haerther.net/

    Thanks to Dashlane for sponsoring the video! If you're techie enough to watch this video, you should be using a password manager. Get a 30-day free trial at https://dashlane.com/tomscott

    I'm at https://tomscott.com
    on Twitter at https://twitter.com/tomscott
    on Facebook at https://facebook.com/tomscott
    and on Instagram as tomscottgo
  • Runtime : 8:26
  • tom scott tomscott the basics computer science two generals problem two generals' problem the two generals problem idempotency idempotency key idempotency token idempotence

COMMENTS: 40

  • Tom Scott
    Tom Scott   3 weeks ago

    Yes, I had help with the graphics for this series. There's no way I'd have animated that myself! On that note, thanks to Dashlane for sponsoring and helping me hire an animator: their free trial link is https://www.dashlane.com/tomscott

  • Carl
    Carl   38 minuts ago

    Hey dude do you still see dead people?oh nevermind.

  • Jake Wish
    Jake Wish   2 hours ago

    What if someone wanted to do the same order for multiple people. A certain restaurant verifies double orders

  • Stuart Wilson
    Stuart Wilson   2 hours ago

    err, Works fine for me... sounds like user error....

  • hmmm
    hmmm   2 hours ago

    No plussed how this solves the two generals actual problem. Poorly explained.

  • Imelda Chandra
    Imelda Chandra   4 hours ago

    I wonder what if like this : Gen A sent message (8 pm) to Gen B Gen B reply (ok. 8 pm) to Gen A is it possible?

  • Imelda Chandra
    Imelda Chandra   4 hours ago

    I wonder what if like this : Gen A sent message (8 pm) to Gen B Gen B reply (ok. 8 pm) to Gen A is it possible? or there is another hindrance?

  • Ailsa Ni
    Ailsa Ni   4 hours ago

    ally with the other general, and then assume the message got through.

  • Verne Jules
    Verne Jules   4 hours ago

    Tom, I understand that the idempotency token/key can solve the problem of double orders/messages. But how does that solve the Two Generals Problem? Forgive my slow brain.

  • Cullenak47
    Cullenak47   5 hours ago

    A sends a messenger to b. If it makes it , b sends both that messenger and a new messenger from b to the castle. Messenger B turns back and messenger A continues to a. B knows if A made it and A knows B made it. Both army’s attack. Solved. I know this wouldn’t work in computers but it is a solution if it were just a puzzle

  • Daniel Newton
    Daniel Newton   8 hours ago

    Have each army send a messenger when they're ready. When the two messengers meet in the middle (taking precautions to avoid getting spotted), each one goes back to their army and says "we're good to go". If the messengers don't make it back, they will assume that they died so can send another, until the two meet and send a return message.

  • Kingsly9802
    Kingsly9802   8 hours ago

    >If you are in computer science and working on a problem that involves potential loss of life, I really hope you aren't watching a series called "The Basics".But they're fun!

  • TheDeathMongrel
    TheDeathMongrel   10 hours ago

    2 Generals is an interesting conundrum in and of itself but I think it's a poor paradigm for avoiding the processing of repeated messages. In 2 Generals, no one proceeds without an acknowledgment. It's a Schrodinger's Cat problem. You don't know the answer until 8 p.m. when either everyone is at the castle or is still waiting for another acknowledgment. Applying idempotency (which would be against the "strict" rules) to 2 Generals, still wouldn't solve the problem. It would only affirm that additional messages, if any, are the same (attack at 8 p.m.), and only if the messages actually make it. 2 Generals doesn't guarantee message delivery in either direction, so even with idempotency tokens, Army B may still take no action if they don't get their acknowledgment.With the delivery issue, if the additional messages don't make it, it doesn't matter, the other side will respond appropriately to the original message. In delivery, the return acknowledgment goes far beyond the 2 Generals' (receipt of message), as you can get an erroneous message, a success or failure, and is likely not to have an effect on processing if no acknowledgment is sent.In any case, I think the delivery problem and applications of idempotency tokens as you've described, is its own best explanation of what's going on, not 2 Generals, which idempotency can't be used to solve (again strict rules).

  • Max Mouse
    Max Mouse   10 hours ago

    General A sends "8pm" General B sends "8pm ack" - General a doesn't attack unless it receives the ack...

  • Aaron
    Aaron   10 hours ago

    General A sends 2 Messengers. Both go to general B to confirm the message was received. Both go to General A but when passing the castle at the exact halfway point one messenger goes back to general b the other goes on to a. They both know the message was received by general b and the acknowledgement got through back to a.

  • Jasmine
    Jasmine   10 hours ago

    An interesting follow up would be the Byzantine general's problem - what if there were multiple generals that could back stab each other?

  • 1dgram
    1dgram   11 hours ago

    Hey, I'm allowed to watch a series called "The Basics" even if I am working on safety of flight software!

  • KryskZ09
    KryskZ09   11 hours ago

    At the point where he's talking about sending 200 messengers, and I'm thinking of a solution right now, I will see how wrong I am once I finish the video.General A sends a messenger to meet a messenger sent by General B half way to the valley, one with a letter of an estimated time and another of "Hey, here's my letter"The messengers swap messages, both now know that once they leave the 50% point they're free of danger. They make their way back to their sending General with the opposing General's note in hand.Repeat this process once the messenger arrives at their designated outpost, this time with the other General agreeing (or disagreeing) with the time. If they disagree, repeat this process.Now they have the correct schedule and a guarantee that the messenger has arrived.Edit: I guess I was incorrect, although my answer wasn't explored. I would assume that it would cause more margin of error though.I still don't understand the concept of an idempotence key, sure you're ensuring nothing if fulfilled twice, but what if it breaks to begin with? There's no way for the other side to know...

  • Aline Fernanda
    Aline Fernanda   12 hours ago

    You are so handsome hehe I like your channel! Greats from Brazil.

  • shinvergil
    shinvergil   12 hours ago

    The example was weak, imo. But good info.

  • X
    X   12 hours ago

    their is an almost guaranteed way to get it to workgeneral A sends a message, general B continues to send a message until general A responses, if another messenger from general B arrives, General A can assume general B didnt receive the message, and send another message, once General As messenger arrived, at which point no more messages from general B will arrive, so they both attackedit: this is under the assumption that the fail rate of messengers is below 100% and their is plenty of time between attacks

  • Mr. Pinkpig
    Mr. Pinkpig   13 hours ago

    Wait couldn't one messenger for A and one messenger from B meet in the valley and give each other a set time?

  • Tulip
    Tulip   13 hours ago

    So this is how the generals communicateMessenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation Messenger one: we attacking at 8General 1:cool let me sound a confirmationMessenger two: i can confirm that we are attacking at 8General 2: alright, let me send a confirmation

  • Killer Germ
    Killer Germ   14 hours ago

    This is a shitty hypothetical, as reasonable suggestions will not be accepted.

  • Jake Hartman
    Jake Hartman   15 hours ago

    pls get patreon and premium memberships and no cemmercials thnx

  • Z-Statistic
    Z-Statistic   15 hours ago

    So the solution to the two generals problem is to send a third of your army into the dangerous valley, all of them with a message to attack at a certain time with the survivors to ally with the other general, and then assume the message got through.

  • Hater Bart
    Hater Bart   16 hours ago

    Initially, I completely misread the title.

  • Eric Tripps
    Eric Tripps   16 hours ago

    So the idempotency token solves the double send error but how does it solve the generals problem?

  • Winston Churchill
    Winston Churchill   17 hours ago

    I know that this video is not about military tactics, but it would be extremely easy, I feel, to coordinate that attack.

  • Paul Brooks
    Paul Brooks   18 hours ago

    Theoretically quantum entanglement, more specifically quantum computing does in fact solve this problem. For reference, research the two slits photon phenomena.

  • Bill Green
    Bill Green   18 hours ago

    I must be missing something as I see how it stops you getting two pizzas but I don't see how it helps the generals at all.

  • Paul Nikonowicz
    Paul Nikonowicz   20 hours ago

    "idempotency". One of the sexiest words in computer science that no one really knows how to pronounce.

  • Matthew Booth
    Matthew Booth   22 hours ago

    I've always pronounced this EYE-dem-POE-tent.

  • David Alan Gilbert
    David Alan Gilbert   22 hours ago

    Now, can you do one that explains why idempotency is pronounced like that? I've always read it as i-dem-potency

  • Arindam Nandi
    Arindam Nandi   22 hours ago

    An interesting follow up would be the Byzantine general's problem - what if there were multiple generals that could back stab each other?

  • D.N.A Travel
    D.N.A Travel   23 hours ago

    Just saw at kings cross, sorry didn't say hello, was running late, love the boss

  • d
    d   23 hours ago

    I thought the title was “2 genders problem” and I came for the comments