The Two Generals’ Problem

Share
Embed
  • Published on Aug 12, 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: www.dashlane.com/tomscott
    MORE BASICS: flash-player.net/p/PL96C35uN7xGLLeET0dOWaKHkAlPsrkcha
    Written by Sean M Elliott and Tom Scott
    Directed by Tomek
    Graphics by Mooviemakers www.mooviemakers.co.uk/
    Audio mix by Haerther Productions 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 dashlane.com/tomscott
    I'm at tomscott.com
    on Twitter at twitter.com/tomscott
    on Facebook at facebook.com/tomscott
    and on Instagram as tomscottgo

Comments • 2 083

  • Tom Scott
    Tom Scott  26 days ago +2603

    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 www.dashlane.com/tomscott

    • Sweet's Channel
      Sweet's Channel 5 hours ago

      Because of the magnitude of the issue... guess it had to do with the implementation of Fetch/Ajax/Json
      Always make sure that communication works as it should with some sort of REST API Tester example with Restlet Client or postman

    • Liberals Get the Bullet Too
      Liberals Get the Bullet Too 2 days ago

      Why don't the two generals have the messengers meet in the middle, and each return with confirmation of having met? This should immediately double the survivability of any particular messenger - they're only travelling half the hostile distance.
      Further, you could have a second set of messengers in an intermediate space to act as a witness or a redundancy.

    • steve d
      steve d 3 days ago

      Doesn"t mention food delivery company by name, shows headline with delivery company's name...

    • Andrew F
      Andrew F 4 days ago

      How is it unsolvable? Wouldn't you just need a maximum of two confirmations sent in order after the original message? If you get at least one confirmation in the correct order after the original message then you know both parties received the original, right? What am I not understanding here?

    • john smith
      john smith 4 days ago +1

      who would put the castle in the valley but a computer tech

  • gepisar
    gepisar 18 minutes ago

    !! I just came from another one of your videos that warns us not say "Tired and Emotional"... i think i know what you mean by "Tired and Exhausted" AND "Tired and Hungry"... is this self-libel?

  • Autotrope
    Autotrope 42 minutes ago

    By your own description of the two generals problem, an idempotency token does not solve the problem.

  • alex chamber
    alex chamber 3 hours ago

    Why don't you keep acknowledging until everyone has more than 3 ack-ah...

    Why don't you send 20 messengers at once? One will get through.... Ah, that too.

    Right time to watch the solution.

  • jammin023
    jammin023 13 hours ago

    I wish these videos had been around back when I was doing Soft Eng at uni... your explanations are so much clearer than my lecturers could manage!

  • Orion Red
    Orion Red 13 hours ago

    This is exactly how I ended up with two gallons of milk in my fridge and two loaves of bread in my cupboard last week. It's also how I ended up with a gallon of spoiled milk and a loaf of stale bread this week.

  • ruwiki
    ruwiki 15 hours ago

    "it's unsolveable"
    me at 2 am: well, there must be a way ...

  • Oz El Coskuner
    Oz El Coskuner 16 hours ago

    Just giving thumbs down for showing 2 long (unskippable) ads. I hope creators puts some pressure on Flash-Player. Because Flash-Player literally don't give a damn about feelings of customers who are not paying. WHY WE STARTED WATCHING Flash-Player? The biggest argument was "so that you don't have to watch long commercials of TV and get brainwashed". Now average ad on Flash-Player is surpassing TV. Anyway, since I got Amazon prime, I reduced Flash-Player time to 2 hours a week. Much happier. And I will never pay for Flash-Player, just because their approach. You cannot shove your will down to people's throat and expect success. When I see Flash-Player logo, I see a RABID DOG with dollar symbols on his red eyes. Disgusting.

  • John Dean
    John Dean 17 hours ago

    There IS answer to the Two Generals' Problem: go to your local chippie.

  • Airpolygon
    Airpolygon 19 hours ago

    Very interesting!

  • Rens Breur
    Rens Breur 20 hours ago

    But this anecdote isn't REALLY an example of the two generals problem right? The only 'attacker' is the server processing the order request. The two generals problem can't be solved by using a unique key.

  • Joseph Thomas
    Joseph Thomas 22 hours ago

    Can you find a different shirt?

  • iammaxhailme
    iammaxhailme 23 hours ago

    "Next time, I'll just cook for myself"

    Or, you can just call the restaurant and place your order verbally. Magic!

    I don't know how it is in the UK, but in NYC you sometimes get it a bit cheaper this way becuase apps take a cut

  • Jonathan Tikhonoff

    Actually the two general story is already solved through encryption system. I know of one encryption system that can confirm to both users at same time that each other got the message. I assume that Deliveroo didn't use such encryption because it might be thought of as a bit too complicated and too costly for such simple service.

    Source: I took cryptography class few years ago so my memory are a bit shaky on details but I clearly remembered Bob, Alice, and Oscar model system about this problem.

  • Nubby Tope
    Nubby Tope Day ago

    The main problem is that they built a castle in a valley.

    • ruwiki
      ruwiki 14 hours ago

      @Nubby Tope as well

    • Nubby Tope
      Nubby Tope 14 hours ago

      ruwiki - fortifications like castles are built on high ground.

    • ruwiki
      ruwiki 15 hours ago

      why? to protect an important river crossing, for example.

  • Zen Lucas-Divers

    wouldn't the best option to just meet somewhere else, send a message to one side and keep doing so until a messenger gets through and tell them to meet a one point so that you can attack together.

  • M
    M Day ago

    And then that "idempotency key" resets when you hit "try again" :D

    • less kiss
      less kiss Day ago

      The fact you spent £1,795 inc vat per minute of this videos graphics is beyond me

  • Techno_mage_21
    Techno_mage_21 Day ago

    Maybe a joke comment cause excuse my incompetence but why isn’t the problem set in 3D? Cause then they could just go around?

  • Zachary Wilson
    Zachary Wilson Day ago

    Are you in the Centre for Computing History in Cambridge?

    • less kiss
      less kiss Day ago

      very close to this idea. Her paper was entitled "Network layer protocols with Byzantine robustness"

  • Caleb_ Artzs
    Caleb_ Artzs Day ago

    Why not A send a messager at same time as B? So both can meet at the middle and both can go back and inform there general's

  • Deep hug
    Deep hug Day ago

    to prevent jamming of wireless signals.

  • soap's alt
    soap's alt Day ago

    The messengers could meet in the valley and then return with an agreement.

    • Jose Rojas
      Jose Rojas Day ago

      without some form of instantaneous communication, neither general will never know with 100% confidence that the other general's messenger made it back safely to relay the agreement. The point is there's always some assumptions made at some point by one general that the last message went through and by the other general that the previously sent messages were sufficient to proceed with 'enough confidence'.

  • BleedingRaindrops

    this is a really cool problem. and a really great explanation. Not being a software engineer myself, a lot of why I'm here is through sheer curiosity, but your explanations are always entertaining and easy to understand, so I keep them on a backlog for the day they become relevant to me. Thanks for keeping this channel awesome.

    • Deep hug
      Deep hug Day ago

      attack. If you stop receiving messages, count 1 for each missed message, Reset counter if you receive a message. If count exceeds 6, attack. If the number "I last saw mess

  • XerO
    XerO Day ago

    couldnt you just send one messenger with a message to have the a messenger from each side to meet at some kind of halfway point and then return to their general

  • George Hugh
    George Hugh Day ago +2

    Castles aren't built in valleys, generally, generally.

    • ruwiki
      ruwiki 15 hours ago

      well, if they protect a river crossing

  • Lou
    Lou Day ago

    You could just get past the castle with your whole force, telling the other force to attack with you - so you become one big army. Problem solved?

  • CS:GO сФинщини

    Bitcoin solved the Byzantine generals' problem

    • ruwiki
      ruwiki 15 hours ago

      blockchain you mean

  • Emily An
    Emily An Day ago

    I earn like 20 quid an hour for deliveroo it’s not bad 😂

  • =NolePtr
    =NolePtr Day ago +5

    I've never heard it referred to as an idempotency key. I've always heard it called a "nonce"

    • jammin023
      jammin023 13 hours ago +3

      The problem is that word means something else in British English...

  • Giovanni Joe
    Giovanni Joe Day ago

    Super informative! Thanks very much for the great content!

    • Emily An
      Emily An Day ago

      story short I got 50 quids worth of Wagamamas for free.

  • flutty bitch
    flutty bitch Day ago

    You are my new favorite channel. Subscribed.
    BTW, I had the same problem when purchasing Dragon Age: Inquisition. Took a month for EA to return my money.

  • Michael Thomas
    Michael Thomas Day ago +1

    "A single human error is never the root cause"
    Tell that to my development manager who came in to the position with nothing more than a background in marketing & graphic design and understands absolutely nothing about coding anything more complicated than changing a few things on an HTML template.

    edit: I don't even work in tech currently, so I'm just meme-ing not speaking from experience.

    • Orion Red
      Orion Red 14 hours ago

      Well, you're dead on.

  • Dan Scherck
    Dan Scherck Day ago

    Interesting factoid: The Spanning Tree Protocol, used in Networking to prevent network loops, was invented by Radia Perlman, whose doctoral thesis at MIT was on something very close to this idea. Her paper was entitled "Network layer protocols with Byzantine robustness"

  • Magic Morgan
    Magic Morgan Day ago +1

    The fact you spent £1,795 inc vat per minute of this videos graphics is beyond me

  • Bluestripe
    Bluestripe Day ago

    I had this with steam with a gift and sent 3 skyrims to my friend, by the time we'd realised the refund was no longer possible.

  • NikoHD203
    NikoHD203 Day ago

    I feel so smart now😂

  • Real Sky Luke
    Real Sky Luke 2 days ago

    *I was a sub before you hit 200k, WTF WHEN DID YOU BLOW UP???!!!!! 1.8 Million!!! I never even noticed!!!!*

  • Reagan Epps
    Reagan Epps 2 days ago

    I know this probably wouldn’t work with computer science stuff but if they sent a messenger to meet the other and they both go back that might work

  • alnoso
    alnoso 2 days ago

    i dont get food delivery apps
    is it so hard to call a human and say "hey i want a pizza"

  • Sebastian Nielsen
    Sebastian Nielsen 2 days ago

    There is actually a way to "solve" this problem, and that is continually send messages. They could contain a number, my message number, and the last message number I saw from you. Of course they must be encrypted and end2end verified.
    Continuially send these messages, lets say with 10 minutes apart. Stop sending messages 1 hour before the attack.
    If you stop receiving messages, count 1 for each missed message, Reset counter if you receive a message. If count exceeds 6, attack.
    If the number "I last saw message number X" is more than 6 - (count), attack.
    Regardless on how the adversiary capture the messages, it will result in a successful attack.
    HINT: This is how alarm system works to prevent jamming of wireless signals.

    • Ptao Tom
      Ptao Tom 2 days ago

      Seems like once both generals have received at least one acknowledgement they can just attack since the time hasn't changed.

  • Black Light
    Black Light 2 days ago

    youtube recommended, wtf? Why? I neither understand computer logics or having problems with my food arriving.

  • Alexander Cavrich
    Alexander Cavrich 2 days ago

    I

    • less kiss
      less kiss 2 days ago

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

  • Drake H.
    Drake H. 2 days ago

    Wouldn't you be able to include a signal response request in the initial message (talking about the two generals problem) - like general a gives a time and requests that general b light a large fire in a visible area to confirm receipt and agreement of the message.

  • [TRCZ] NoidEXE
    [TRCZ] NoidEXE 2 days ago

    4:55 but how can you make the same order three times and the server not notice it's the same order? I mean can't you use a pseudo random number generator or something? You only get the next random number if you receive a confirmation or cancel the order. That way if the server gets the same random number for the same client it can tell it's the same order. I'm just a game designer so maybe it's harder than this but I can't think of why it wouldn't work.

    • less kiss
      less kiss 2 days ago

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

  • Mike Pratt
    Mike Pratt 2 days ago

    Suggestion for dinner next time - Salmon in a dishwasher..?

  • Alexi Hickin
    Alexi Hickin 2 days ago +1

    I work for deliveroo and I remember this evening, i delivered Wagamamas to a house who had already received their order. I had to wait with them while they got a refund, long story short I got 50 quids worth of Wagamamas for free.

  • Alexi Hickin
    Alexi Hickin 2 days ago

    I earn like 20 quid an hour for deliveroo it’s not bad 😂

  • Raymon Crane
    Raymon Crane 2 days ago

    Those look like HP 7933/7935 disk drives in back. Used to fix those back in the day.

  • roasted pancakes
    roasted pancakes 2 days ago

    Just send two million messengers with a paper each towards the blue army. The paper should have a time to attack and a check mark at the bottom of the page. Make the blue army check every single paper and send all of the messengers back. Then both armies will have a reasonable guarantee that each army got the message. Alternatively, reroute one of the armies to meet the other army and have a combined attack with both armies.

  • TelFiRE
    TelFiRE 2 days ago

    There’s nothing unethical about ordering food. I work for Grubhub. Yes there are things I would rather have different, but wouldn’t at their job? By not ordering food all you’re doing is denying me money and making my job harder

    • TelFiRE
      TelFiRE 2 days ago

      And frankly the only unethical think you’re is to frame this is a question of ethics. Businesses are allowed to have different policies and people are allowed to agree or disagree on those policies without it being a matter of ethics. If you don’t want to work there you don’t have to

  • Simon Johnson
    Simon Johnson 2 days ago

    It's not "unsolvable", the word is "insuperable - Pedant

    • Ask to seduce Miss
      Ask to seduce Miss 2 days ago

      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

  • invisiblebears
    invisiblebears 2 days ago

    Why couldn't they just continually send back messengers with confirmation until the proposed time and if one of the messengers didn't show up Abort or in the case of a computer disconnect or and endhandshake?

    • Ask to seduce Miss
      Ask to seduce Miss 2 days 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

  • lampree
    lampree 2 days ago

    why did this video get uploaded 3 times??

  • Robert South
    Robert South 2 days ago

    Seems like once both generals have received at least one acknowledgement they can just attack since the time hasn't changed.

  • 007one
    007one 2 days ago

    Bitcoin

  • TheTech9
    TheTech9 2 days ago

    This channel is awsome, and this guy is pleasant voice to listen to. No homo

  • Carl
    Carl 2 days ago

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

  • Jake Wish
    Jake Wish 2 days ago

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

  • Stuart Wilson
    Stuart Wilson 2 days ago

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

  • Tinka Like AngelOK
    Tinka Like AngelOK 2 days ago

    Justeat 😂

  • hmmm
    hmmm 2 days ago

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

  • xirsamoht x
    xirsamoht x 3 days ago

    Speckled Jim & his friends!

  • Imelda Chandra
    Imelda Chandra 3 days 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 3 days 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?

    • Poldovico
      Poldovico Day ago

      Gen B doesn't know that A got the message

  • Ailsa Ni
    Ailsa Ni 3 days ago

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

  • Verne Jules
    Verne Jules 3 days 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.

    • Ailsa Ni
      Ailsa Ni 3 days 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

  • Cullenak47
    Cullenak47 3 days ago +1

    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 3 days ago +1

    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 3 days ago +2

    >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!

  • soSAMuk's UK slot channel

    Why do kids toys adverts have to say “batteries not included?”

  • TheDeathMongrel
    TheDeathMongrel 3 days 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 3 days ago

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

  • Aaron
    Aaron 3 days ago +3

    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.

    • Mike Nerone
      Mike Nerone Day ago

      This assumes that a messenger can only be killed at the exact halfway point. You can't make that assumption. Remember that this is a dramatization of a real communications problem in computer networking. A data packet could be lost *anywhere* along the path. Further, even if you did send two packets (messengers) in parallel, there's no way to get one of them to turn around at the halfway point (indeed, there's not even a way to determine that a packet has *reached* the halfway point).

  • Jasmine
    Jasmine 3 days 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 3 days ago

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

    • 1dgram
      1dgram 3 days ago

      @Jasmine It's one if those words that are pronounced differently in the UK than in the US. You have the correct American pronunciation.

    • Jasmine
      Jasmine 3 days ago

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