logical time and clocks

64
Logical Time and Clocks Ken Birman Cornell University. CS5410 Fall 2008.

Upload: shira

Post on 23-Feb-2016

30 views

Category:

Documents


0 download

DESCRIPTION

Logical Time and Clocks. Ken Birman Cornell University. CS5410 Fall 2008. . Recall cloud “layers”. Highest level consists of applications These are composed from services that run on data harvested by applications using tools Map-Reduce - PowerPoint PPT Presentation

TRANSCRIPT

Creating a Trustworthy Active Web

Logical Time and ClocksKen Birman

Cornell University. CS5410 Fall 2008. Recall cloud layersHighest level consists of applicationsThese are composed from services that run on data harvested by applications using tools Map-ReduceThe overall system is managed by a collection of core infrastructure services, such as locking and node status trackingHow can we reason about the behavior of such components?The scale and complexity makes it seem hard to say more than Heres a service. This is what it does

But we can do moreWe can describe distributed systems in more rigorous ways that let us say stronger things about them

The trick is to start at the bottom, not the top

This week: well focus on concepts of time as they arise in distributed systemsWhat time is it?In distributed system we need practical ways to deal with timeE.g. we may need to agree that update A occurred before update BOr offer a lease on a resource that expires at time 10:10.0150 Or guarantee that a time critical event will reach all interested parties within 100msBut what does time mean?Time on a global clock?E.g. with GPS receiver or on a machines local clockBut was it set accurately?And could it drift, e.g. run fast or slow?What about faults, like stuck bits? or could try to agree on timeLamports approachLeslie Lamport suggested that we should reduce time to its basicsTime lets a system ask Which came first: event A or event B?In effect: time is a means of labeling events so thatIf A happened before B, TIME(A) < TIME(B)If TIME(A) < TIME(B), A happened before BDrawing time-line pictures:pmsndp(m)qrcvq(m) delivq(m)DDrawing time-line pictures:A, B, C and D are events. Could be anything meaningful to the applicationSo are snd(m) and rcv(m) and deliv(m)What ordering claims are meaningful?pmACBsndp(m)qrcvq(m) delivq(m)DDrawing time-line pictures:A happens before B, and C before DLocal ordering at a single processWrite and pqmACBrcvq(m) delivq(m)sndp(m)

DDrawing time-line pictures:sndp(m) also happens before rcvq(m)Distributed ordering introduced by a messageWritepqmACBrcvq(m) delivq(m)sndp(m)

DDrawing time-line pictures:A happens before DTransitivity: A happens before sndp(m), which happens before rcvq(m), which happens before DpqmDACBrcvq(m) delivq(m)sndp(m)Drawing time-line pictures:B and D are concurrentLooks like B happens first, but D has no way to know. No information flowedpqmDACBrcvq(m) delivq(m)sndp(m)Happens before relationWell say that A happens before B, written AB, ifAPB according to the local ordering, orA is a snd and B is a rcv and AMB, orA and B are related under the transitive closure of rules (1) and (2)So far, this is just a mathematical notation, not a systems toolLogical clocksA simple tool that can capture parts of the happens before relationFirst version: uses just a single integerDesigned for big (64-bit or more) countersEach process p maintains LTp, a local counterA message m will carry LTmRules for managing logical clocksWhen an event happens at a process p it increments LTp. Any event that matters to pNormally, also snd and rcv events (since we want receive to occur after the matching send)When p sends m, setLTm = LTpWhen q receives m, setLTq = max(LTq, LTm)+1Time-line with LT annotationsLT(A) = 1, LT(sndp(m)) = 2, LT(m) = 2LT(rcvq(m))=max(1,2)+1=3, etcpqmDACBrcvq(m) delivq(m)sndp(m)LTq0001111333455LTp0112222223333Logical clocksIf A happens before B, AB,then LT(A)