Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s...

40
Time Supriya Vadlamani
  • date post

    15-Jan-2016
  • Category

    Documents

  • view

    233
  • download

    0

Transcript of Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s...

Page 1: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Time

Supriya Vadlamani

Page 2: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Asynchrony v/s Synchrony

• Last class:– Asynchrony • Event based• Lamport’s Logical clocks

• Today:– Synchrony• Use real world clocks• But do all the clocks show the same time?

Page 3: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Problem Statement

Given a collection of processes that can. . .– Only communicate with significant latency– Only measure time intervals approximately– Fail in various ways

We want to construct a shared notion of time.

“The only reason for time is so that everything doesn't happen at once.” – Albert Einstein

Page 4: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Why is The Problem Hard?

• Variation of transmission delays – Each process cannot have an instantaneous global

view

• Presence of drift in clocks.

• Support faulty elements Hardest !

Page 5: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Applications that Require Synchronization

• Transaction processing applications• Process control applications• Communication protocols – require approximately the same view of time

Page 6: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Approaches to Clock Synchronization

• Hardware vs Software clocks

• External vs Internal Clock synchronization

Page 7: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Hardware Clocks

• Each processor has an oscillator• BUT- oscillators drift!

Logical Clock = H/w clock + Adjustment Factor

Page 8: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Software Clocks

1. Deterministic assumes an upper bound on transmission delays – guarantees some precision

2. Statistical expectation and standard deviation of the delay distributions are known

3. Probabilistic no assumptions about delay distributions

Reliable ?

Realistic ?

Any Guarantees ?

Page 9: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Clock Synchronization

External Clock Synchronization Internal Clock Synchronization

Synchronize clocks with respect to an external time referenceExample: NTP

Synchronize clocks among themselves

Page 10: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Today…Optimal Clock Synchronization [Srikanth and Toueg ’87]– Assume reliable network (deterministic)– Internal clock synchronization – Also optimal with respect to failures

Authors:

Sam Toueg – Cornell University-Moved to MIT

T K Srikanth- Cornell University

Page 11: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Types of Failures in a Network

• Up to f processes can fail in the following ways:– Crash Failure: • processor behaves correctly and then stops executing

forever– Performance Failure: • processor reacts too slowly to a trigger event( Eg:Clock

too slow or fast, Stuck clock bits)– Arbitrary Failure (a.k.a Byzantine):• processor executes uncontrolled computation

Page 12: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

System Model

Assumptions:• Clock drift is bounded

(1 – ρ)(t – s) ≤ Hp(t) – Hp(s) ≤ (1 + ρ)(t – s)• Communication and processing are reliable

trecv - tsend ≤ tdel

• Authenticated messageswill relax this later...

Page 13: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Goals

• Property 1 Agreement: Bounded drift btw processes

| Lpi(t) – Lpj(t) | δ (δ is the precision of the clock synchronization algorithm)

• Property 2 Accuracy: Bounded drift within a process

(1 – ρv)(t – s) + a ≤ Lp(t) – Lp(s) ≤ (1 + ρv)(t – s) + b

Page 14: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Goals

• Optimal Accuracy– Drift rate bounded by the maximum drift rate of

correct hardware clocksρv = ρ

Page 15: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Outline

• Synchronization algorithm – authentication• Optimizing for accuracy• Properties• Synchronization algorithm – broadcast • Initialization and Integration

Page 16: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Synchronization Algorithm(Authenticated Messages)

P – logical time between resynchronizations

kth resynchronization - Waiting for time kP

real time t

Ready to synchronize

logical time kP

Page 17: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Synchronization Algorithm(Authenticated Messages)

P – logical time between resynchronizations

logical time kP

Ready to synchronize

Page 18: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Synchronization Algorithm(Authenticated Messages)

P – logical time between resynchronizations

logical time kP

Ready to synchronize

Page 19: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Synchronization Algorithm(Authenticated Messages)

P – logical time between resynchronizations

logical time kP

kP +

Synchronize!

Page 20: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Achieving Optimal Accuracy

Uncertainty of tdelay

difference in the logical time between resynchronizations

Reason for non-optimal accuracy

Solution:Slow down or speed up the logical clocks.Slow down to kP+α when Ck

i-1 reads min(T+β, kP+β)

Speed up to kP+α when Cki-1 reads max(T-β, kP+β)

Page 21: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Properties Essential to the Algorithm

Unforgeability:No process broadcasts no correct process accepts by t

Relay:Correct process accepts message at time t, others do so by time t + tdel

Correctness:Round k: f+1 broadcast messages received by t+tdel

Page 22: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Broadcast Primitive

• Strong authentication is too heavyweight. Only need:– Unforgeability– Relay– Correctness

• Can use a broadcast primitive from the literature.

Page 23: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Synchronization Algorithm(Broadcast Primitives)

• Replace signed communication with a broadcast primitive – Primitive relays messages automatically– Cost of O(n2) messages per resynchronization

• New limit on number of faulty processes allowed:– n > 3f

Page 24: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Broadcast based Synchronization Algorithm

(echo, round k)

Received f + 1 distinct

(init, round k)!

1

Received f + 1 distinct

(echo, round k)!

2

Received 2f + 1 distinct

(echo, round k)!Accept (round k)

3

Page 25: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Take Away

• Deterministic algorithm– Simple algorithm– Unified solution for different types of failures– Achieves “optimal” accuracy– O(n2) messages– Bursty communication

Page 26: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Today..

• Probabilistic Internal Clock Synchronization [Cristian and Fetzer ’03]– Drop requirements on network (probabilistic)– Internal Clock synchronization

• Authors Flaviu CristianChristof Fetzer (TU Dresden)UC San Diego

Page 27: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

How is the second paper different ?

• Deterministic approach– Bound on

transmission delays

• Require N2 messages

• Unified solution for all failures

• Bursty communication

• Probabilistic approach– No upper bound on

transmission delays

• Requires N+1 messages(best case)

• Caters to every kind of failure

• Staggered communication

Page 28: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Motivation for Probabilistic Synch.

• Traditional deterministic fault-tolerant clock synchronization algorithms:– Assume bounded communication delays– Require the transmission of at least N2

messages each time N clocks are synchronized– Bursty exchange of messages within a narrow

re-synchronization real-time interval

Page 29: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

System Model

• Correct clocks still have bounded drift

• No longer a maximum communication delay– delays given by probability distribution

• There is a known minimum message delay tmin

Page 30: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Outline

• Probabilistic Clock Reading, (2 processors)• Optimizing probabilistic clock reading• Round Message exchange protocol• Failure algorithm classes

Page 31: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Contents of Exchanged Messages

If q trusts p can also use it to approximate other clocks.

Message (p->q)

Send time

Estimation of all clocks

Error bounds

Receive time stamps of q

Page 32: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Probabilistic Clock Reading

• Basic Idea:

T0 T2

T1

m1 m2

(T2 – T0)(1 + ) = maximum bound (real time)min ≤ t(m2) ≤ (T2 – T0)(1 + ) - min

max(m2)(1 + ) + min(m2)(1 - )2

Cq = T1 +

p

q

Page 33: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Probabilistic Clock Reading

• Basic Idea:

T0 T2

T1

m1 m2

p

q

Is error ≤ ?Yes: SuccessNo? Try reading again

(Limit: D)

Maximum acceptable clock reading error

Page 34: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Techniques to Optimize Probabilistic Clock Reading

• Use all potentially non-concurrent messages– Helpful to approximate the sender’s/receiver’s

clocks

• Stagger the messages– Increases no. of non concurrent messages,

reduces n/w congestion

• Transitive Remote clock reading– Possible when no arbitrary failures

Page 35: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Staggering Messages

Cycle

p

q

r

Slot

A slot is a unit in which a single process gets to sendA cycle is a unit in which all processes get a chance to sendA round is a unit in which all processes must get estimates of other clocks

A slot is a unit in which a single process gets to sendA cycle is a unit in which all processes get a chance to sendA round is a unit in which all processes must get estimates of other clocks

Round

Page 36: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Round Message Exchange Protocol

Reply Mode

Clock times:

p q r

10 11 10

? ? ?reply messages

t

err

Request Mode

Clock times:

p q r

? ? ?

? ? ?request messages

t

err

Finish Mode

finish messages

t

err

Clock times:

p q r

10 11 10

1 1 2

Page 37: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Failure Classes

Algo Tolerated Failures

Required Processes

Tolerated Failures

CSA Crash F F+1 Crash

CSA Read F 2F+1 Crash, Reading

CSA Arbit. F 3F+1 Arbit, Reading

CSA Hybrid Fc, Fr, Fa 3Fa+2Fr+Fc+1 Crash, Read, Arb

Page 38: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Take away

• Probabilistic algorithm– Takes advantage of the current working

conditions, by invoking successive round-trip exchanges, to reach a tight precision)

– Precision is not guaranteed– Achieves “optimal” accuracy– O(n) messages

If both algorithms achieve optimal accuracy,

Then why is there still work being done?

Page 39: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

References

• Thanks to – Lakshmi Ganesh– Michael George

• Papers:– Optimal Clock Synchronization, Srikanth and Toueg. JACM 34(3), July 1987.– F. Schneider. Understanding protocols for Byzantine clock synchronization.

Technical Report 87-859, Dept of Computer Science, Cornell University, Aug 1987.

– Using Time Instead of Timeout for Fault-Tolerant Distributed Systems, Lamport. ACM TOPLAS 6:2, 1974.

– Probabilistic Internal Clock Synchronization, Cristian and Fetzer.

Page 40: Time Supriya Vadlamani. Asynchrony v/s Synchrony Last class: – Asynchrony Event based Lamport’s Logical clocks Today: – Synchrony Use real world clocks.

Initialization and Integration

• Same algorithms are used– A process independently starts clock Co

– On accepting a message at real time t, it sets C0 = α

• “Passive” scheme for integration of new processes– Joining process find out the current round number– Prevents a joining process from affecting the correct

processes in the system