v ector c locks p2p s ystems
play

[V ECTOR C LOCKS & P2P S YSTEMS ] Shrideep Pallickara Computer - PDF document

CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University CS 555: D ISTRIBUTED S YSTEMS [V ECTOR C LOCKS & P2P S YSTEMS ] Shrideep Pallickara Computer Science Colorado State University CS555: Distributed


  1. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University CS 555: D ISTRIBUTED S YSTEMS [V ECTOR C LOCKS & P2P S YSTEMS ] Shrideep Pallickara Computer Science Colorado State University CS555: Distributed Systems [Fall 2019] September 5, 2019 L4.1 Dept. Of Computer Science , Colorado State University Frequently asked questions from the previous class survey L4. 2 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L6.1 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

  2. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Topics covered in this lecture ¨ Vector Clocks ¨ Peer to Peer (P2P) Systems ¤ Characteristics ¤ Generations ¤ P2P middleware and requirements L4. 3 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA V ECTOR C LOCKS CS555: Distributed Systems [Fall 2019] September 5, 2019 L4.4 Dept. Of Computer Science , Colorado State University L6.2 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

  3. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Lamport’s Clocks order events based on the happened-before relationship ¨ If a happened before b , then C(a) < C(b) ¨ But nothing can be said about two events a and b by merely comparing their values ¨ C(a) < C(b) ? ¤ Does not mean a happened before b L4. 5 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA Let’s look a little closer ¨ T snd (m i ) : Time m i was sent ¨ T rcv (m i ) : Time m i was received ¨ T snd (m i ) < T rcv (m i ) ¨ BUT ¤ T snd (m i ) < T rcv (m j ) ? n NO L4. 6 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L6.3 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

  4. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Concurrent message transmissions 0 0 0 Sending m3 MAY HAVE m1 depended on m1 6 8 10 m2 16 12 20 T rcv (m1) < T snd (m2) 18 24 30 24 32 40 But sending of m2 has nothing m3 40 30 50 to do with receipt of m1 36 48 60 61 42 70 m4 m5 Lamport clocks do not capture 48 69 80 causality 70 77 90 85 76 100 L4. 7 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA Vector clocks ¨ Developed by Mattern [1989] and Fidge [1991] to overcome shortcomings of Lamport’s clocks ¤ i.e. if C(a) < C(b) then we cannot conclude a à b ¨ A vector clock for a system of N processes is an array of N integers ¨ Each process keeps its own vector clock VC i ¤ Process uses it vector clock to timestamp messages L4. 8 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L6.4 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

  5. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Causality can be captured by Vector clocks ¨ Event a is known to causally precede event b iff • VC(a) < VC(b) ¨ Each process P i maintains a vector VC i ¨ VC i [i] is number of events so far at P i ¨ If VC i [j] = k ¤ P i knows k events occurred at P j ¤ P i ’s knowledge of local time at P j L4. 9 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA Causal precedence can be captured by Vector clocks ¨ Event a is known to causally precede event b iff VC(a) < VC(b) ¤ VC(a)<VC(b) iff VC(a)[k] ≤ VC(b)[k] for all k and at least one of those relationships is strictly smaller ¨ Each process P i maintains a vector VC i ¨ VC i [i] is number of events so far at P i ¨ If VC i [j] = k ¤ P i knows k events occurred at P j ¤ P i ’s knowledge of local time at P j L4. 10 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L6.5 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

  6. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Vectors are piggybacked along with any messages that are sent ① Before executing an event (sending, delivering, or internal) P i executes VC i [i] = VC i [i] + 1 ¤ ② When P i sends a message m to P j Set m ’s timestamp ts(m) to VC i after doing (1) ¤ ③ After receiving m, process P j adjusts its vector VC j [k] = max{VC j [k], ts(m)[k]} for each k ¤ Execute step (1) and deliver ¤ L4. 11 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA Vector clocks example 1 [1,0,0] [2,0,0] A [2,2,0] B [2,1,0] C [2,2,2] [0,0,1] L4. 12 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L6.6 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

  7. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Vector clocks example 2 [5,4,0] [1,0,0] [7,4,4] A [1,3,0] B [1,2,0] [1,4,0] C [1,3,4] [1,3,3] L4. 13 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA Vector timestamps allow us to determine causality and concurrency ¨ Event a happened before event b iff • ts(a) ≤ ts (b) for each process i • And one of those relationships is strictly smaller ¨ If this is not true ¤ Events a and b are concurrent L4. 14 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L6.7 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

  8. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Vector Clocks: Other aspects ¨ If event a has timestamp, ts(a) : ¤ ts(a) [i]–1 n Denotes number of events at P i that precede a ¨ When P j receives message m from P i with timestamp ts(m) =VC i ¤ P j knows about number of events at P i that causally preceded m ¤ Also, P j knows about how many events at other processes have preceded the sending of m , and on which m may causally depend L4. 15 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA Vector clocks: Disadvantages ¨ Storage and message payload is proportional to N , the number of processes ¨ It’s been shown ([Charron-Bost 1991]) that if we are to tell if two events are concurrent by inspecting timestamps? ¤ The dimension of N is unavoidable L4. 16 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L6.8 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

  9. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University U SING V ECTOR C LOCKS FOR C AUSALLY ORDERED M ULTICASTING CS555: Distributed Systems [Fall 2019] September 5, 2019 L4.17 Dept. Of Computer Science , Colorado State University Contrasting totally-ordered and causally-ordered multicasting ¨ Causally-ordered multicasting is weaker than totally-ordered multicasting ¨ If two messages are not in any way related to each other? ¤ We do not care about the order in which they are delivered to applications ¤ Could be delivered in different order at different applications L4. 18 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L6.9 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

  10. CS555: Distributed Systems [Fall 2019] Dept. Of Computer Science , Colorado State University Using Vector Clocks for causally-ordered multicasting ¨ Clocks are ONLY adjusted when sending and receiving messages ¨ Upon sending a message, process P i will only increment VC i [i] by 1 ¨ When P i delivers a message m with timestamp ts(m) it adjusts VC i [k] ¤ To max ( VC i [k], ts(m) [k] ) for each k L4. 19 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA When process P j receives a message m from P i ¨ Delivery of the message m to the application layer is delayed until 2 conditions are met: ① ts(m) [i] = VC j [i] + 1 n This means m is the next message that P j was expecting from P i ② ts(m) [k] ≤ VC j [k] for all k ≠ i n This means that P j has seen all messages that have been seen by P i when it receives m L4. 20 CS555: Distributed Systems [Fall 2019] September 5, 2019 Dept. Of Computer Science , Colorado State University Professor: S HRIDEEP P ALLICKARA L6.10 S LIDES C REATED B Y : S HRIDEEP P ALLICKARA

Recommend


More recommend