Distributed computing time

22
TIME AND GLOBAL STATES Deepak John Department Of Computer Applications,SJCET-Pala

description

Distributed Computing,Time and Global States

Transcript of Distributed computing time

Page 1: Distributed computing time

TIME AND GLOBAL STATES

Deepak John Department Of Computer Applications,SJCET-Pala

Page 2: Distributed computing time

IntroductionIntroduction Time is an Important and interesting issue in distributes systems.

One we can measure accurately. Can use as a metric.y Consistency of distributed data, transactions, authenticity checks

(ticket lifetimes),duplication detection, distributed debugging andb d t ti tgarbage detection, etc.

A device that count oscillations occurring in a crystal at a definitefrequencyq y

Hardware time: Hi(t) The counts of oscillation since an original pointS ft ti C ( ) H ( )+ Software time: Ci(t) = Hi(t)+ Timestamp of an event

Page 3: Distributed computing time

Clock skew and clock drift

l k kClock skewInstantaneous difference between readings of any two clocksClock driftVariations in how clocks count time (oscillations in a crystal), whichcause divergence between clocks

Network

Page 4: Distributed computing time

Clock synchronization using a time server: Cristian’smethod

mr

m tp Time server,S

Periodically, each machine sends a message to the time serverasking for the current timeg� Machine responds with CUTC as fast as it can

Page 5: Distributed computing time
Page 6: Distributed computing time

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Page 7: Distributed computing time

1 The master polls the slaves’ clocks

The Berkeley algorithms1. The master polls the slaves’ clocks2. The master estimates the slaves’ clocks by round-trip time

Similar to Christian’s algorithmg3. The master averages the slaves’ clock values

Cancel out the individual clock’s tendencies to run fast or lslow

4. The master sends back to the slaves the amount that the slaves’clocks should adjust by Positive or negative value Avoid further uncertainty due to the message transmission

timetime Slave adjust its clock

Page 8: Distributed computing time

NTP: The Network Time Protocol- Mills To provide a service enabling clients across the internet to be

synchronized accurately to UTC NTP employs techniques for filtering of timing data and it

discriminates between the quality of timing data from differentdiscriminates between the quality of timing data from differentservers.

To provide a reliable service that can survive lengthy losses ofconnectivity: There are redundant servers and redundant paths between servers;

server can reconfigure in case of failuresserver can reconfigure in case of failures. scale to large number of clients and servers To provide protection against interference with the time service To provide protection against interference with the time service

whether accidental or malicious

Page 9: Distributed computing time

Hierarchical structure for the time servers NTP servers synchronize with each other in one of three modes: in

the order of accuracy.1. Multicast mode Intend for use on a high speed LAN Intend for use on a high speed LAN Assuming a small delay Low accuracy but efficient

2. Procedure-call mode Similar to Christian’s Higher accuracy than multicast Higher accuracy than multicast

3. Symmetric mode The highest accuracyg y

Reconfigure when servers become unreachable

Page 10: Distributed computing time

An example synchronization subnet in an NTP implementation

1

Primary servers areconnected to a timesource,

2 2

Secondary serversare synchronizedwith primary servers.

3 3 3

p y

Note: Arrows denote synchronization control, numbers denote strata.

Page 11: Distributed computing time

Messages exchanged between a pair of NTP peersAll messages use UDP and so deliver unreliably.Each message carries three time stamps: sent time, recd time, time ofthis message.

Ti-1Ti-2Server BTime

g

m m'

TiTi- 3Server ATime

Page 12: Distributed computing time

Logical Time and logical ClockLogical Time and logical Clock Logical time is an alternative; it gives ordering of events, rather than

exact timestamp of occurrence. Happen-before relation (→) is a partial order on events that reflects a

flow of information between them.Th l f ‘H B f ’ l ti Three rules for ‘Happen Before’ relation.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Page 13: Distributed computing time

Logical clocks (LC)Logical clocks (LC) Logical clock is a monotonically increasing software counter that is

updated according to the happened-before relationship betweentevents.

Each process pi has a logical clock Li, which can be used to applylogical timestamps to events.logical timestamps to events.

Rules or Lamports algorithm for logical clocks:The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Page 14: Distributed computing time

Events occurring at three processesThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Page 15: Distributed computing time

Lamport timestamps

e e` L(e) < L(e`) L(e) < L(e`) e e` or e||e` L(e) L(e ) e e or e||e

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Page 16: Distributed computing time

Vector Clock A vector clock for a system of N processes is an array of N integersy p y g Each process keeps its own vector clock Vi, which it uses to

timestamp local event Processes piggyback vector timestamps on the messages they send Processes piggyback vector timestamps on the messages they send

to one another

Page 17: Distributed computing time

Global StateGlobal State The global state of a distributed computation is the set of local states

of all individual processes involved in the computation plus the stateof the communication channels.

The set of local states for a global set called the “cut”. A cutrepresents the last event that has been recorded for each of severalrepresents the last event that has been recorded for each of severalprocesses. All recorded message receipts have a corresponding recorded send

event

Page 18: Distributed computing time

A cut C is consistent if for each event it contains all the events thathappened-before(HB) that event.An inconsistent cut would have a receipt of a message but nocorresponding send event.A consistent global state is one that corresponds to a consistent cut

p1

e 10

e 11

e 12

e 13

A consistent global state is one that corresponds to a consistent cut.

m1 m2

p2Physical p2 time

Inconsistent cut

e 20

e 21

e 22

Consistent cutInconsistent cut

Page 19: Distributed computing time

Distributed garbage collectionRequirements of global states

Based on reference counting Should include the state of communication channels. referring object may be in a message in transit referring object may be in a message in transit.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Page 20: Distributed computing time

Distributed deadlock detection Look for “waits-for”

relationship Distributed termination

detection.detection. consider a system where each

process is active or passive.h k b we check processes one-by-

one; has the systemterminated if all are passive?p

p2 is passive but there is amessage for p1 in transit

Distributed debuggingDistributed debuggingNeed collect values of distributed variables at the same time

Page 21: Distributed computing time

Chandy and Lamport’s Snapshot Algorithm Assume the distributed system can be represented as a collection of Assume the distributed system can be represented as a collection of

processes connected to each other through uni-directional point-to-point communication channels.

the algorithm may be initiated by any process. Consider twoprocesses P and Q P records its own local state P records its own local state It sends a marker along each of its outgoing channels, indicating

that the receiver should participate in recording the global state. When process Q receives the marker through an incoming

channel C, its action depends on whether or not it has alreadysaved its local statesaved its local state

Page 22: Distributed computing time

Marker receiving rule for process piOn pi’s receipt of a marker message over channel c:

if ( h t t d d it t t ) itif (pi has not yet recorded its state) itrecords its process state now;records the state of c as the empty set;turns on recording of messages arriving over other incoming

channels;else

pi records the state of c as the set of messages it has received over csince it saved its state.

end ifend ifMarker sending rule for process pi

After pi has recorded its state, for each outgoing channel c:p sends one marker message over cpi sends one marker message over c(before it sends any other message over c).