Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Computing

Similar presentations


Presentation on theme: "Distributed Computing"— Presentation transcript:

1 Distributed Computing
Umar Kalim Dept. of Communication Systems Engineering 19/12/2007 Fall 2007 cs425

2 Agenda Synchronization Algorithms Physical Clocks Christian Berkeley
Averaging NTP (Network Time Protocol) Fall 2007 cs425 Ref: COMP 212, University of Liverpool

3 What can go wrong? Updating a replicated database: Update 1 adds 100 rupees to an account, Update 2 calculates and adds 1% interest to the same account. Clock reading might be different for different computers! Inconsistent state Fall 2007 cs425

4 What to do? Include the time of every update in the update message
Clock synchronization Order events in the network Logical clock Transactions Distributed Mutual Exclusion Distributed Transactions Fall 2007 cs425

5 Computer Clock We need to measure time accurately:
to know the time an event occurred at a computer Algorithms for clock synchronization useful for concurrency control based on timestamp ordering authenticity of requests e.g. in Kerberos etc Each computer in a DS has its own internal clock Even if clocks on all computers in a DS are set to the same time, their clocks will eventually vary quite significantly unless corrections are applied Fall 2007 cs425

6 Synchronization based on “Actual Time”
Note: time is really easy on a uniprocessor system. Achieving agreement on time in a DS is not trivial. Question: is it even possible to synchronize all the clocks in a Distributed System? With multiple computers, “clock skew” ensures that no two machines have the same value for the “current time”. But, how do we measure time? Fall 2007 cs425

7 How do we measure time? Turns out that we have only been measuring time accurately with a “global” atomic clock since Jan. 1st, 1958 (the “beginning of time”). Refer to pages of the textbook for all the details – it’s quite a story. Bottom Line: measuring time is not as easy as one might think it should be. Fall 2007 cs425

8 Universal Coordinated Time (UTC)
International Atomic Time is based on very accurate physical clocks (drift rate 10-13) UTC is an international standard for time keeping It is based on atomic time, but occasionally adjusted to astronomical time It is broadcast from radio stations on land and satellite (e.g. GPS) Computers with receivers can synchronize their clocks with these timing signals Signals from land-based stations are accurate to about millisecond Signals from GPS are accurate to about 1 microsecond Fall 2007 cs425

9 Clock Synchronization
There exists a time server receiving signals from a UTC source Cristian’s algorithm There is no UTC source available Berkley’s algorithm Exact time does not matter! Lamport’s algorithm Fall 2007 cs425

10 Clock Synchronization Algorithms
Each machine has a timer that causes an interrupt every H seconds. Results in an increment of the software clock that keeps track of the number of ticks since some agreed time. Let the value of the clock be C. When the UTC time is t, the value of the clock in this machine p is Cp(t). Ideal circumstances Cp(t) = t for all p and all t Fall 2007 cs425

11 Clock Synchronization Algorithms
Fall 2007 cs425

12 Clock Synchronization Algorithms
Problem: Real timers do not cause an interrupt exactly H times a second For example For a timer H=60 there should be 216,000 ticks per hour In practice, chips have an error of 10-5 Meaning that the range will be 215,998 to 216,002 per hour Thus, if a constant ρ exists such that 1-ρ ≤ dC/dt ≤ 1+ρ ρ is known as the maximum drift rate Fall 2007 cs425

13 Clock Synchronization
Thus at a time Δt two clocks drifting apart from UTC may be as much as 2ρΔt To guarantee that clocks do not drift apart more than δ, they must be synchronized every δ/2ρ Fall 2007 cs425

14 Clock Sync. Algorithm: Cristian's
Every computer periodically asks the “time server” for the current time The server responds ASAP with the current time CUTC The client sets its clock to CUTC Fall 2007 cs425

15 Problems Major problem: if time from time server is less than the client - resulting in time running backwards on the client! (Which cannot happen – time does not go backwards). Introduce changes gradually Minor problem: results from the delay introduced by the network request/response: latency Best estimate (T1-T0)/2 If the interrupt handling time, I, is known, (T1-T0-I)/2 Use series of measurements Fall 2007 cs425

16 Berkeley Algorithm An algorithm for internal synchronization of a group of computers A master polls to collect clock values from the others (slaves) The master uses round trip times to estimate the slaves’ clock values It takes an average It sends the required adjustment to the slaves (better than sending the time which depends on the round trip time) If master fails, can elect a new master to take over Fall 2007 cs425

17 The Berkeley Algorithm
The time daemon asks all the other machines for their clock values The machines answer The time daemon tells everyone how to adjust their clock Fall 2007 cs425

18 Berkeley Algorithm Fall 2007 cs425

19 Berkeley Algorithm Average time: 3:05 Fall 2007 cs425

20 Other Algorithms Both Cristian’s and the Berkeley Algorithm are centralised algorithms. Decentralised algorithms also exist, and the Internet’s Network Time Protocol (NTP) is the best known and most widely implemented. NTP can synchronize clocks to within a 1—50 msec accuracy. Fall 2007 cs425

21 Averaging Algorithms Every R seconds, each machine broadcasts its current time. The local machine collects all other broadcast time samples during some time interval, S. The simple algorithm: the new local time is set as the average of the value received from all other machines. Improved algorithm: Correct each message by adding to the received time an estimate of the propagation time from the ith source (extra probe messages are needed to use this scheme). Fall 2007 cs425

22 Network Time Protocol Uses a network of time servers to synchronize all processors on a network. Time servers are connected by a synchronization subnet tree. The root is adjusted directly . Each node synchronizes its children nodes. Fall 2007 cs425

23 NTP Contact a time server to ask the time.
What is the major issue here? Trick is to get a good estimate of the message delays. Fall 2007 cs425

24 NTP NTP is about making clocks correspond to the real time.
Clock servers are divided into stratums, starting with stratum-0 for the reference physical clock. If a stratum-2 clock is running faster than a stratum-1 clock, the stratum-2 clock will adjust. How should it adjust if it is running fast? Time should never go backwards, but should just slow down. Fall 2007 cs425

25 Summary & Questions? That’s all for today! Fall 2007 cs425


Download ppt "Distributed Computing"

Similar presentations


Ads by Google