Sequential Computation The Consensus Problem Roger Wattenhofer thread a lot of kudos to memory Maurice Herlihy and Costas Busch Distributed for some of Computing their slides Group object object Distributed Computing Group Roger Wattenhofer 2 Concurrent Computation Asynchrony s d a e r h t • Sudden unpredictable delays memory – Cache misses ( short ) – Page faults ( long ) – Scheduling quantum used up ( really long ) object object Distributed Computing Group Roger Wattenhofer 3 Distributed Computing Group Roger Wattenhofer 4
Model Summary Road Map • Multiple threads • We are going to focus on principles – Sometimes called processes – Start with idealized models – Look at a simplistic problem • Single shared memory – Emphasize correctness over pragmatism • Objects live in memory – “Correctness may be theoretical, but • Unpredictable asynchronous delays incorrectness has practical impact” Distributed Computing Group Roger Wattenhofer 5 Distributed Computing Group Roger Wattenhofer 6 You may ask yourself … Fundamentalism • Distributed & concurrent systems are I’m no theory weenie - why all hard the theorems and proofs? – Failures – Concurrency • Easier to go from theory to practice than vice-versa Distributed Computing Group Roger Wattenhofer 7 Distributed Computing Group Roger Wattenhofer 8
The Two Generals Communications Red army wins Red armies send If both sides messengers across valley attack together Distributed Computing Group Roger Wattenhofer 9 Distributed Computing Group Roger Wattenhofer 10 Communications Your Mission Design a protocol to ensure that red armies attack simultaneously Messengers don’t always make it Distributed Computing Group Roger Wattenhofer 11 Distributed Computing Group Roger Wattenhofer 12
Theorem Proof Strategy • Assume a protocol exists There is no non-trivial • Reason about its properties protocol that ensures the red • Derive a contradiction armies attacks simultaneously Distributed Computing Group Roger Wattenhofer 13 Distributed Computing Group Roger Wattenhofer 14 Proof Fundamental Limitation 1. Consider the protocol that sends • Need an unbounded number of fewest messages messages 2. It still works if last message lost • Or possible that no attack takes place 3. So just don’t send it – Messengers’ union happy 4. But now we have a shorter protocol! 5. Contradicting #1 Distributed Computing Group Roger Wattenhofer 15 Distributed Computing Group Roger Wattenhofer 16
You May Find Yourself … You might say I want a real-time YAFA I want a real-time YAFA I want a real-time YAFA compliant Two Generals compliant Two Generals compliant Two Generals Yes, Ma’am, right away! Yes, Ma’am, right away! protocol using UDP datagrams protocol using UDP datagrams protocol using UDP datagrams running on our enterprise-level running on our enterprise-level running on our enterprise-level fiber tachyion network ... fiber tachyion network ... fiber tachyion network ... Distributed Computing Group Roger Wattenhofer 17 Distributed Computing Group Roger Wattenhofer 18 You might say You might say Advantage: Advantage: Advantage: I want a real-time dot-net I want a real-time dot-net •Buys time to find another job •Buys time to find another job •Buys time to find another job compliant Two Generals compliant Two Generals Disadvantage: Disadvantage: •No one expects software to work •No one expects software to work •No one expects software to work Yes, Ma’am, right away! Yes, Ma’am, right away! protocol using UDP datagrams protocol using UDP datagrams •You’re doomed •You’re doomed anyway anyway anyway running on our enterprise-level running on our enterprise-level •Without this course, you may •Without this course, you may fiber tachyion network ... fiber tachyion network ... not even know you’re doomed not even know you’re doomed Distributed Computing Group Roger Wattenhofer 19 Distributed Computing Group Roger Wattenhofer 20
You might say You might say Advantage: Advantage: I want a real-time YAFA I want a real-time YAFA •No need to take course •No need to take course I can’t find a fault-tolerant I can’t find a fault-tolerant compliant Two Generals compliant Two Generals I can’t find a fault-tolerant I can’t find a fault-tolerant algorithm, I guess I’m just a algorithm, I guess I’m just a protocol using UDP datagrams protocol using UDP datagrams algorithm, I guess I’m just a algorithm, I guess I’m just a pathetic loser. pathetic loser running on our enterprise-level running on our enterprise-level pathetic loser. pathetic loser fiber tachyion network ... fiber tachyion network ... Distributed Computing Group Roger Wattenhofer 21 Distributed Computing Group Roger Wattenhofer 22 You might say You might say Advantage: Advantage: I want a real-time YAFA I want a real-time YAFA •No need to take course •No need to take course I can’t find a fault-tolerant compliant Two Generals compliant Two Generals I can’t find a fault-tolerant Disadvantage: Using skills honed in course, I Disadvantage: Using skills honed in course, I algorithm, I guess I’m just a protocol using UDP datagrams protocol using UDP datagrams algorithm, I guess I’m just a can avert certain disaster! can avert certain disaster! •Boss fires you, hires •Boss fires you, hires pathetic loser running on our enterprise-level running on our enterprise-level pathetic loser •Rethink problem spec, or •Rethink problem spec, or University St. Gallen graduate University St. Gallen graduate fiber tachyion network ... fiber tachyion network ... •Weaken requirements, or •Weaken requirements, or •Build on different platform •Build on different platform Distributed Computing Group Roger Wattenhofer 23 Distributed Computing Group Roger Wattenhofer 24
Consensus: Each Thread has a They Communicate Private Input 19 32 21 Distributed Computing Group Roger Wattenhofer 25 Distributed Computing Group Roger Wattenhofer 26 They Agree on Some Thread’s Consensus is important Input • With consensus, you can implement 19 anything you can imagine… 19 19 • Examples: with consensus you can decide on a leader, implement mutual exclusion, or solve the two generals problem Distributed Computing Group Roger Wattenhofer 27 Distributed Computing Group Roger Wattenhofer 28
Consensus #1 You gonna learn shared memory • In some models, consensus is possible • n processors, with n > 1 • In some other models, it is not • Processors can atomically read or write (not both) a shared memory cell • Goal of this and next lecture: to learn whether for a given model consensus is possible or not … and prove it! Distributed Computing Group Roger Wattenhofer 29 Distributed Computing Group Roger Wattenhofer 30 Protocol (Algorithm?) Unexpected Delay • There is a designated memory cell c. ??? ??? • Initially c is in a special state “?” • Processor 1 writes its value v 1 into c, Swapped out then decides on v 1 . back at • A processor j (j not 1) reads c until j reads something else than “?”, and then decides on that. Distributed Computing Group Roger Wattenhofer 31 Distributed Computing Group Roger Wattenhofer 32
Fault-Tolerance Heterogeneous Architectures ??? ??? ??? ??? yawn 286 Pentium Pentium Distributed Computing Group Roger Wattenhofer (1) 33 Distributed Computing Group Roger Wattenhofer 34 Consensus #2 Wait-Free Implementation wait-free shared memory • n processors, with n > 1 • Every process (method call) completes in a finite number of steps • Processors can atomically read or write (not both) a shared memory cell • Implies no mutual exclusion • Processors might crash (halt) • We assume that we have wait-free atomic registers (that is, reads and • Wait-free implementation… huh? writes to same register do not overlap) Distributed Computing Group Roger Wattenhofer 35 Distributed Computing Group Roger Wattenhofer 36
A wait-free algorithm… Is the algorithm correct? 17 32 cell c • There is a cell c, initially c=“?” ? • Every processor i does the following ? ? r = Read(c); if (r == “?”) then 32 Write(c, v i ); decide v i ; 32! else 17 17! decide r; time Distributed Computing Group Roger Wattenhofer 37 Distributed Computing Group Roger Wattenhofer 38 Theorem: Proof Strategy No wait-free consensus • Make it simple ??? ??? – n = 2, binary input • Assume that there is a protocol • Reason about the properties of any such protocol • Derive a contradiction Distributed Computing Group Roger Wattenhofer 39 Distributed Computing Group Roger Wattenhofer 40
Recommend
More recommend