Lecture 12: Time Distributed Systems

Similar documents
Lecture 10: Clocks and Time

Distributed Systems COMP 212. Lecture 17 Othon Michail

Distributed Systems. Clock Synchronization: Physical Clocks. Paul Krzyzanowski

Synchronisation in. Distributed Systems. Co-operation and Co-ordination in. Distributed Systems. Kinds of Synchronisation. Clock Synchronization

Last Class: Naming. Today: Classical Problems in Distributed Systems. Naming. Time ordering and clock synchronization (today)


Clock-Synchronisation

Time in Distributed Systems

Distributed Systems. 05. Clock Synchronization. Paul Krzyzanowski. Rutgers University. Fall 2017

Clock and Time. THOAI NAM Faculty of Information Technology HCMC University of Technology

Time Synchronization and Logical Clocks

Synchronization Part 1. REK s adaptation of Claypool s adaptation of Tanenbaum s Distributed Systems Chapter 5

Synchronization. Distributed Systems IT332

TIME ATTRIBUTION 11/4/2018. George Porter Nov 6 and 8, 2018

Time. COS 418: Distributed Systems Lecture 3. Wyatt Lloyd

Time Synchronization and Logical Clocks

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Last Class: Naming. DNS Implementation

CSE 5306 Distributed Systems. Synchronization

CSE 124: TIME SYNCHRONIZATION, CRISTIAN S ALGORITHM, BERKELEY ALGORITHM, NTP. George Porter October 27, 2017

CSE 5306 Distributed Systems

DISTRIBUTED REAL-TIME SYSTEMS

2. Time and Global States Page 1. University of Freiburg, Germany Department of Computer Science. Distributed Systems

INTERNATIONAL JOURNAL OF ENGINEERING SCIENCES & RESEARCH TECHNOLOGY

Distributed Coordination 1/39

Distributed Systems. Time, clocks, and Ordering of events. Rik Sarkar. University of Edinburgh Fall 2014

Verteilte Systeme (Distributed Systems)

Chapter 6 Synchronization (1)

Selected Questions. Exam 2 Fall 2006

殷亚凤. Synchronization. Distributed Systems [6]

Basic vs. Reliable Multicast

Proseminar Distributed Systems Summer Semester Paxos algorithm. Stefan Resmerita

Middleware and Distributed Systems. Time. Martin v. Löwis. Mittwoch, 22. Februar 12

Synchronization. Clock Synchronization

Distributed Systems Exam 1 Review. Paul Krzyzanowski. Rutgers University. Fall 2016

Ad hoc and Sensor Networks Time Synchronization

Clock Synchronization. Synchronization. Clock Synchronization Algorithms. Physical Clock Synchronization. Tanenbaum Chapter 6 plus additional papers

Time in Distributed Systems

Distributed Systems. Pre-Exam 1 Review. Paul Krzyzanowski. Rutgers University. Fall 2015

Distributed Systems COMP 212. Revision 2 Othon Michail

System Models 2. Lecture - System Models 2 1. Areas for Discussion. Introduction. Introduction. System Models. The Modelling Process - General

2017 Paul Krzyzanowski 1

OUTLINE. Introduction Clock synchronization Logical clocks Global state Mutual exclusion Election algorithms Deadlocks in distributed systems

Experiment on Cristian s and Berkeley Time Synchronization Algorithms

Implementing a NTP-Based Time Service within a Distributed Middleware System

Distributed Operating Systems. Distributed Synchronization

Advanced Topics in Distributed Systems. Dr. Ayman A. Abdel-Hamid. Computer Science Department Virginia Tech

Distributed Systems Exam 1 Review Paul Krzyzanowski. Rutgers University. Fall 2016

TIME AND SYNCHRONIZATION. I. Physical Clock Synchronization: Motivation and Challenges

Process groups and message ordering

Lecture 7: Logical Time

The Timed Asynchronous Distributed System Model By Flaviu Cristian and Christof Fetzer

Distributed systems. Lecture 6: distributed transactions, elections, consensus and replication. Malte Schwarzkopf

Chapter 6 Ti T me m s ynchronization

Wireless Communication Bluetooth, Timing

Coordination 1. To do. Mutual exclusion Election algorithms Next time: Global state. q q q

Chapter 6 Synchronization

Clock Synchronization

The Flooding Time Synchronization Protocol

Implementing NTP. Release 3.8.0

THE TRANSPORT LAYER UNIT IV

Distributed Systems Synchronization

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

Table of Contents 1 NTP Configuration 1-1

Implementing NTP. Support was added for IPv6 addresses, VRFs, multicast-based associations, and burst and iburst modes for poll-based associations.

Operation Manual NTP. Table of Contents

Byzantine Fault Tolerance and Consensus. Adi Seredinschi Distributed Programming Laboratory

Configuring NTP. Information About NTP. This chapter contains the following sections:

Midterm Examination ECE 419S 2015: Distributed Systems Date: March 13th, 2015, 6-8 p.m.

Time Handling in Programming Language

Configuring NTP. Information About NTP. This chapter contains the following sections:

IEEE 1588 PTP clock synchronization over a WAN backbone

Synchronization. Chapter 5

Synchronization of Network Devices Time by GPS Based Network Time Protocol Output

Distributed Deadlock

µtasker Document µtasker SNTP (Simple Network Time Protocol)

This chapter describes how to configure the Network Time Protocol (NTP) on Cisco NX-OS devices. This chapter includes the following sections:

Network Time Protocol

Distributed Systems (ICE 601) Fault Tolerance

Distributed Systems. replication Johan Montelius ID2201. Distributed Systems ID2201

Timing in Packet Networks. Stefano RUffini 9 March 2015

CS 417: the one-hour study guide for exam 2

Distributed Systems. Day 7: Time and Snapshots [Part 1]

Fault-Tolerant Computer Systems ECE 60872/CS Recovery

Coordination 2. Today. How can processes agree on an action or a value? l Group communication l Basic, reliable and l ordered multicast

Replication in Distributed Systems

Distributed Synchronization. EECS 591 Farnam Jahanian University of Michigan

CSE 486/586 Distributed Systems

Failure Tolerance. Distributed Systems Santa Clara University

HP 6125 Blade Switch Series

Frequently asked questions from the previous class survey

HP 6125G & 6125G/XG Blade Switches

Recent Work on OSC Timetags at CNMAT

Introduction to Real-Time Communications. Real-Time and Embedded Systems (M) Lecture 15

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

Coordination and Agreement

Distributed Systems. 09. State Machine Replication & Virtual Synchrony. Paul Krzyzanowski. Rutgers University. Fall Paul Krzyzanowski

Arranging lunch value of preserving the causal order. a: how about lunch? meet at 12? a: <receives b then c>: which is ok?

Configuring NTP. Information About NTP. Information About the NTP Server. This chapter contains the following sections:

System Models for Distributed Systems

Transcription:

Lecture 12: Time Distributed Systems Behzad Bordbar School of Computer Science, University of Birmingham, UK Lecture 12 1

Overview Time service requirements and problems sources of time Clock synchronisation algorithms clock skew & drift Cristian algorithm Berkeley algorithm Network Time Protocol Logical clocks Lamport s timestamps Lecture 12 2

Time service Why needed? to measure delays between distributed components to synchronise streams, e.g. sound and video to establish event ordering causal ordering (did A happen before B?) concurrent/overlapping execution (no causal relationship) for accurate timestamps to identify/authenticate business transactions serializability in distributed databases security protocols Lecture 12 3

Clocks Internal hardware clock built-in electronic device counts oscillations occurring in a quartz crystal at a definite frequency store the result in a counter register interrupt generated at regular intervals interrupt handler reads the counter register, scales it to convert to time units (seconds, nanoseconds) and updates software clock Lecture 12 4

Clock skew and drift Clock skew difference between the readings of two clocks Clock drift Network difference in reading between a clock and a nominal perfect reference clock per unit of time of the reference clock typically 10-6 seconds/second = 1 sec in 11.6 days Lecture 12 5

Sources of time Universal Coordinated Time (UTC, from French) based on atomic time but leap seconds inserted to keep in phase with astronomical time (Earth s orbit) UTC signals broadcast every second from radio and satellite stations land station accuracy 0.1-10ms due to atmospheric conditions Global Positioning System (GPS) broadcasts UTC Receivers for UTC and GPS available commercially used to synchronise local clocks Lecture 12 6

Clock synchronisation External: synchronise with authoritative source of time the absolute value of difference between the clock and the source is bounded above by D at every point in the synchronisation interval time accurate to within D Internal: synchronise clocks with each other the absolute value of difference between the clocks is bounded above by D at every point in the synchronisation interval clocks agree to within D (not necessarily accurate time) Lecture 12 7

Clock compensation Assume 2 clocks can each drift at rate R msecs/sec maximum difference 2R msecs/sec must resynchronise every D/2R to agree within D Clock correction get UTC and correct software clock Problems! what happens if local clock is 5 secs fast and it is set right? timestamped versions of files get confused time must never run backwards! better to scale the value of internal clock in software without changing the clock rate Lecture 12 8

Synchronisation methods Synchronous systems simpler, relies on known time bounds on system actions Asynchronous systems intranets Cristian s algorithm Berkeley algorithm Internet The Network Time Protocol Lecture 12 9

Synchronous systems case Internal synchronisation between two processes know bounds MIN, MAX on message delay also on clock drift, execution rate Assume One sends message to Two with time t Two can set its clock to t + (MAX+MIN)/2 (estimate of time taken to send message) then the skew is at most (MAX-MIN)/2 why not t + MIN or t + MAX? maximum skew is larger, could be MAX-MIN Lecture 12 10

Cristian s algorithm T0 T1 Client Request UTC Time Time server h = interrupt handler time Time Server with UTC receiver gives accurate current time Estimate message propagation time by p=(t 1 -T 0 -h)/2 (=half of round-trip of request-reply) Set clock to UTC+p Make multiple requests, at spaced out intervals, measure T 1 -T 0 but discard any that are over a threshold (could be congestion) or take minimum values as the most accurate Lecture 12 11

Cristian s algorithm Probabilistic behaviour achieves synchronisation only if round-trip short compared to required accuracy high accuracy only for message transmission time close to minimum Problems single point of failure and bottleneck could multicast to a group of servers, each with UTC an impostor or faulty server can wreak havoc use authentication agreement protocol for N > 3f clocks, f number of faulty clocks Lecture 12 12

The Berkeley algorithm Choose master co-ordinator which periodically polls slaves Master estimates slaves local time based on round-trip Calculates average time of all, ignoring readings with exceptionally large propagation delay or clocks out of synch Sends message to each slave indicating clock adjustment 3:00:00 0 +5 3:00:00 3:00:01 3:00:02 3:00:00 3:00:00-10 +25 +15-20 2:59:50 3:00:25 2:59:51 3:00:26 2:59:52 3:00:27 Query Response Adjust Synchronisation feasible to within 20-25 msec for 15 computers, with drift rate of 2 x 10-5 and max round trip propagation time of 10 msec. Lecture 12 13

The Berkeley algorithm Accuracy depends on the round-trip time Fault-tolerant average: eliminates readings of faulty clocks - probabilistically average over the subset of clocks that differ by up to a specified amount What if master fails? elect another leader How? Lecture 12 14

Network Time Protocol (NTP) Multiple time servers across the Internet Primary servers: directly connected to UTC receivers Secondary servers: synchronise with primaries Tertiary servers: synchronise with secondary, etc Scales up to large numbers of servers and clients 1 2 2 3 3 3 = active synchronisation = backup synchronisation (exchange timing information, but do not use it to synchronise clocks) Copes with failures of servers e.g. if primary s UTC source fails it becomes a secondary, or if a secondary cannot reach a primary it finds another one. Authentication used to check that time comes from trusted sources Lecture 12 15

NTP Synchronisation Modes Multicast one or more servers periodically multicast to other servers on high speed LAN they set clocks assuming small delay Procedure Call Mode similar to Cristian s algorithm: client requests time from a few other servers used for higher accuracy or where no multicast Symmetric protocol used by master servers on LANs and layers closest to primaries highest accuracy, based on pairwise synchronisation Lecture 12 16

Logical time For many purposes it is sufficient to agree on the same time (e.g. internal consistency) which need not be UTC time Can deduce causal event ordering a b (a occurs before b) Logical time denotes causal relationships but the relationship may not reflect real causality, only accidental Lecture 12 17

Event ordering Define a b (a occurs before b) if a and b are events in the same process and a occurs before b, or a is the event of message sent from process A and B is the event of message receipt by process B If a b and b c then a c. is partial order. For events such that neither a b nor b a we say a, b are concurrent, denoted a b. Lecture 12 18

Example of causal ordering p 1 a b m 1 p 2 c d m 2 Physical time p 3 e a b, c d b c, d f a e f Lecture 12 19

Logical clocks [Lamport] Logical clock = monotonically increasing software counter (not real time!) one for each process P, used for timestamping How it works L P incremented before assigning a timestamp to an event when P sends message m, P timestamps it with current value t of L P (after incrementing it), piggybacking t with m on receiving message (m,t), Q sets its own clock L Q to maximum of L Q and t, then increments L Q before timestamping the message receive event Note a b implies T(a) < T(b) Lecture 12 20 What about converse?

Totally ordered logical clocks 1 2 p 1 a b m 1 p 2 3 4 c d m 2 Physical time p 3 1 e Problem: T(a) = T(e), and yet a, e distinct. Create total order by taking account of process ids. Then (T(a),pid) < (T(b),qid) iff T(a) < T(b) or T(a)=T(b) and pid < qid. Lecture 12 21 f 5

Vector clocks Totally ordered logical clocks arbitrary event order, depends on order of process ids i.e. (T(a),pid) < (T(b),qid) does not imply a b, see a, e Vector clocks array of N logical clocks in each process, if N processes vector timestamps piggybacked on the messages rules for incrementing similar to Lamport s, except processes own component in array modified componentwise maximum and comparison Problems storage requirements Lecture 12 22

Vector timestamps (1,0,0) (2,0,0) p 1 a b m 1 p 2 (2,1,0) (2,2,0) c d m 2 Physical time p 3 (0,0,1) e f (2,2,2) VT(b) < VT(c), hence b c neither VT(b) < VT(e), nor VT(b) < VT(e), hence b e Lecture 12 23

Summary Local clocks drift! but needed for timestamping Synchronisation algorithms must handle variable message delays Clock compensation estimate average delays adjust clocks can deal with faulty clocks Logical clocks sufficient for causal ordering Lecture 12 24

Exercises: 11.2 A clock is reading 10:27:54 (hr:min:sec) when it is discovered to be 4 seconds fast. Explain why it is undesirable to set it back to the right time at that point and show (numerically) how it should be adjusted so as to be correct after 8 seconds has elapsed. 11.3 A scheme for implementing ai-mast-once reliable message delivery uses synchronized clocks to reject duplicate messages. Processes place their local clock value (a timestamp ) in the messages they send. Each receiver keeps a table giving. for each sending process, the largest message timestamp it has seen. Assume that clocks are synchronized to within 100 ms, and that messages can arrive at most 50 ms after. transmission. Lecture 12 25

Exercises: (i) When may a process ignore a message bearing a timestamp T, if it has recorded the last message received from that process as having timestamp T? (ii) When may a receiver remove a timestamp 175,000 (ms) from its table? (Hint: use the receiver s local clock value.) (iii) Should the clocks be internally synchronized or externally synchronized? 11.4 A client attempts to synchronize with a time server. It records the roundtrip times and \ timestamps returned by the server in the table below. Which of these times should it use to set its clock? To what time should it set it? Estimate t the accuracy of the setting with respect to the server s clock. If it is known that the time between sending and receiving a message in the system concerned is at least 8 ms, do your answers change? Round Trip Time (hr:min:sec) 22 l0:54:23.674 25 l0:54:25.450 20 10:54:28.342 Lecture 12 26