The Two Generals’ Problem

Share
HTML-code
  • Published: 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

Comments • 2 122

  • Tom Scott
    Tom Scott   4 weeks back

    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

    • Sweet's Channel
      Sweet's Channel  2 days back

      @Masked Death True... I admit that the reply was a bit aggressive. I Should have been more polite from the start. Have a nice day 😊👌

    • Masked Death
      Masked Death  2 days back

      @Sweet's Channel no problem, mistakes happen, sorry for lashing out - your reply was a bit aggressive and it caught me off guard. My bad.

    • Sweet's Channel
      Sweet's Channel  2 days back

      @Masked Death oh... now I understand. your talking about the sponsor of the video. I'm sorry 😔

    • Sweet's Channel
      Sweet's Channel  2 days back

      @Masked Death No it doesn't. the issue talked about in the video... starting at 3:00 it has to do with the implementation of Fetch/Ajax/Json

      the coder should have made sure that communication works as it should with some sort of REST API Tester example with Restlet Client or postman

      I'm not aggressive but frustrated because the app you are talking about is app for end user and not a coders broblem

    • Masked Death
      Masked Death  2 days back

      @Sweet's Channel yes it does, it's an alternative to Dashlane except you don't have to pay for it. Not sure why your response is so aggressive unless you're shilling for Dashlane tho

  • Bibi Mizrah
    Bibi Mizrah  5 hours back

    Dash Lane is good. If you want self hosted multi device password manager that’s open source I recommend Bitwarden

    • deka W
      deka W  9 hours back

      Are you sure you want to send this form again?

      • 607
        607  9 hours back

        Ah! When I was in Rome in 2016 with school (a Dutch school), a few text messages sent to me on one of the days, from two different people, arrived 3-6 times each, with an interval between each time that seemed to increase. Maybe that could have been solved by such an idempotency key system! In fact, maybe the messages _do_ have one, but my phone simply doesn't do anything with it.

        • blooDDragoNNetwork
          blooDDragoNNetwork  16 hours back

          This guy is something between 20 and 60 years old i cant tell

          • ben brunyee
            ben brunyee  17 hours back

            Try IBM MQ

            • Burning Wang
              Burning Wang  22 hours back

              I use just eat, never used Deliveroo so I’m reet

              • Bernd Knauer
                Bernd Knauer  1 days back

                Send smoke signals, PrObLeM SoLvEd

                • Christian Rasmussen
                  Christian Rasmussen  1 days back

                  Neat. I'll float this to pupils who might appreciate this kind of problem. :)

                  • Stephen Cooper
                    Stephen Cooper  1 days back

                    There is a fix though, General A just sends the messenger over and over again until they receive a reply?! General B knows that as long as the message keeps arriving then his own messenger hasn't gotten through?!

                    • Lysergesaure1
                      Lysergesaure1  1 days back

                      7:40 you can definitely bribe the company to make the app send the master pasword to their servers, and none would be the wiser. Use something open source, and audited.

                      • Guinness
                        Guinness  1 days back

                        What you're saying is use the order, user and date but not the time add the key?

                        • Guinness
                          Guinness  1 days back

                          Easy way to run a scam

                          • Dominic Quick
                            Dominic Quick  1 days back

                            Make sure the same soldier gets back?

                            • Ahmad Pujianto
                              Ahmad Pujianto  2 days back

                              This is quiet a basic thing for payment gateway.. System should consider multiple order as a sign of failure, either in user device or on any infrastructure within the system itself.

                              • فاء بن ألف'
                                فاء بن ألف'  2 days back

                                Can’t just 1 red messenger send the message then come back?

                                • فاء بن ألف'
                                  فاء بن ألف'  2 days back

                                  And if they want confirmation the blue’s would send one and verify it then go back, it doesn’t have to arrive even; both of them would attack anyway and they’ll win

                              • Souvik Aswad
                                Souvik Aswad  2 days back

                                Great video!

                                • J Espinola
                                  J Espinola  2 days back

                                  How did this not happen sooner?

                                  • Yasir Arshad
                                    Yasir Arshad  2 days back

                                    So like free food?

                                    • Silverwolf0080
                                      Silverwolf0080  2 days back

                                      So what would be the equivalent of the idempotency for the two generals. Damn it, now I'm gonna be thinking about that all day.

                                      • Brian Bacc
                                        Brian Bacc  2 days back

                                        you're awesome subbed and liked

                                        • gepisar
                                          gepisar  2 days back

                                          !! 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  2 days back

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

                                            • alex chamber
                                              alex chamber  3 days back

                                              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  3 days back

                                                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  3 days back

                                                  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  3 days back

                                                    "it's unsolveable"

                                                    me at 2 am: well, there must be a way ...

                                                    • Stephen Cooper
                                                      Stephen Cooper  1 days back

                                                      General A just sends the messenger over and over again until they receive a reply?! General B knows that as long as the message keeps arriving then his own messenger hasn't gotten through?

                                                  • Oz El Coskuner
                                                    Oz El Coskuner  3 days back

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

                                                    • John Dean
                                                      John Dean  3 days back

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

                                                      • Airpolygon
                                                        Airpolygon  3 days back

                                                        Very interesting!

                                                        • Rens Breur
                                                          Rens Breur  3 days back

                                                          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  3 days back

                                                            Can you find a different shirt?

                                                            • iammaxhailme
                                                              iammaxhailme  3 days back

                                                              "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
                                                                Jonathan Tikhonoff  3 days back

                                                                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  4 days back

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

                                                                  • ruwiki
                                                                    ruwiki  3 days back

                                                                    @Nubby Tope as well

                                                                  • Nubby Tope
                                                                    Nubby Tope  3 days back

                                                                    ruwiki - fortifications like castles are built on high ground.

                                                                  • ruwiki
                                                                    ruwiki  3 days back

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

                                                                • Zen Lucas-Divers
                                                                  Zen Lucas-Divers  4 days back

                                                                  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  4 days back

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

                                                                    • less kiss
                                                                      less kiss  4 days back

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

                                                                  • Techno_mage_21
                                                                    Techno_mage_21  4 days back

                                                                    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  4 days back

                                                                      Are you in the Centre for Computing History in Cambridge?

                                                                      • less kiss
                                                                        less kiss  4 days back

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

                                                                    • Caleb_ Artzs
                                                                      Caleb_ Artzs  4 days back

                                                                      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  4 days back

                                                                        to prevent jamming of wireless signals.

                                                                        • soap's alt
                                                                          soap's alt  4 days back

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

                                                                          • Jose Rojas
                                                                            Jose Rojas  4 days back

                                                                            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
                                                                          BleedingRaindrops  4 days back

                                                                          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  4 days back

                                                                            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  4 days back

                                                                          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  4 days back

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

                                                                            • ruwiki
                                                                              ruwiki  3 days back

                                                                              well, if they protect a river crossing

                                                                          • Lou
                                                                            Lou  4 days back

                                                                            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  3 days back

                                                                                blockchain you mean

                                                                            • Emily An
                                                                              Emily An  4 days back

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