Distributed Systems COMP 212. Lecture 17 Othon Michail

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

Distributed Systems COMP 212. Revision 2 Othon Michail

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

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

Lecture 10: Clocks and Time

Time Synchronization and Logical Clocks

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

Lecture 12: Time Distributed Systems

Time Synchronization and Logical Clocks

CSE 5306 Distributed Systems. Synchronization

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

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

Clock-Synchronisation

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

Distributed Coordination 1/39

Time in Distributed Systems

Synchronization. Distributed Systems IT332

Distributed Systems. Clock Synchronization: Physical Clocks. Paul Krzyzanowski

Proseminar Distributed Systems Summer Semester Paxos algorithm. Stefan Resmerita

CSE 5306 Distributed Systems

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

殷亚凤. Synchronization. Distributed Systems [6]

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

Synchronization. Clock Synchronization

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

Chapter 6 Synchronization

Verteilte Systeme (Distributed Systems)

Last Class: Naming. DNS Implementation

Distributed Operating Systems. Distributed Synchronization

Synchronization. Chapter 5

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

Time in Distributed Systems

SYNCHRONIZATION. DISTRIBUTED SYSTEMS Principles and Paradigms. Second Edition. Chapter 6 ANDREW S. TANENBAUM MAARTEN VAN STEEN

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

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

DISTRIBUTED REAL-TIME SYSTEMS

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

Replication in Distributed Systems

Distributed Systems. coordination Johan Montelius ID2201. Distributed Systems ID2201

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

INTERNATIONAL JOURNAL OF ENGINEERING SCIENCES & RESEARCH TECHNOLOGY

ICT 6544 Distributed Systems Lecture 7

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

Chapter 6 Synchronization (1)

Distributed Synchronization. EECS 591 Farnam Jahanian University of Michigan

Network Time Protocol

2017 Paul Krzyzanowski 1

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

EECS 498 Introduction to Distributed Systems


Lecture 7: Logical Time

Failure Tolerance. Distributed Systems Santa Clara University

Implementing NTP. Release 3.8.0

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

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

Distributed Systems Synchronization

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

Distributed Systems COMP 212. Lecture 19 Othon Michail

Large Systems: Design + Implementation: Communication Coordination Replication. Image (c) Facebook

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [DISTRIBUTED MUTUAL EXCLUSION] Frequently asked questions from the previous class survey

Wireless Communication Bluetooth, Timing

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

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

CSE 486/586 Distributed Systems

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

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

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

Experiment on Cristian s and Berkeley Time Synchronization Algorithms

Implementing NTPv4 in IPv6

Process groups and message ordering

CSE 124: LAMPORT AND VECTOR CLOCKS. George Porter October 30, 2017

Last time. Distributed systems Lecture 6: Elections, distributed transactions, and replication. DrRobert N. M. Watson

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

IEEE 1588 PTP clock synchronization over a WAN backbone

CSE 380 Computer Operating Systems

Last Class: Clock Synchronization. Today: More Canonical Problems

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

Process Synchroniztion Mutual Exclusion & Election Algorithms

Introduction to Distributed Systems Seif Haridi

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

The Design and Implementation of a Fault-Tolerant Media Ingest System

Basic vs. Reliable Multicast

Chapter 6 Ti T me m s ynchronization

Primary-Backup Replication

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

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

Important Lessons. A Distributed Algorithm (2) Today's Lecture - Replication

IEEE 1588 Hardware Assist

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

Congestion control in TCP

Causal Consistency and Two-Phase Commit

CMPSCI 677 Operating Systems Spring Lecture 14: March 9

Coordination and Agreement

Lecture 6: Logical Time

Timing in Packet Networks. Stefano RUffini 9 March 2015

Distributed Systems Principles and Paradigms

in Berlin (Germany) Sponsored by Motorola Semiconductor NEC Electronics (Europe) Siemens Semiconductors Organized by

System Models for Distributed Systems

Synchronisation and Coordination (Part 2)

Configuring Precision Time Protocol (PTP)

Transcription:

Distributed Systems COMP 212 Lecture 17 Othon Michail

Synchronisation 2/29

What Can Go Wrong Updating a replicated database: Customer (update 1) adds 100 to an account, bank employee (update 2) adds 1% interest to the same account Clock reading might be different for different computers! Inconsistent state 3/29

Possible Solutions Include the time of every update in the update message Clock synchronisation Order events in the network Logical clock Transactions 4/29

Computer Clock We need to measure time accurately: to know the time an event occurred at a computer Algorithms for clock synchronisation are useful for concurrency control based on timestamp ordering authenticity of requests e.g. in Kerberos 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 5/29

Synchronisation 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 synchronise all the clocks in a Distributed System? With multiple computers, due to clock skew, different machines do not in general have the same value for the current time But, how do we measure time? 6/29

How Do We Measure Time? Turns out that we have only been measuring time accurately with a global atomic clock since Jan. 1 st, 1958 (the beginning of time ) Refer to 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 7/29

Coordinated Universal 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 synchronise their clocks with these timing signals Signals from land-based stations are accurate to about 0.1-10 millisecond Signals from GPS are accurate to about 1 microsecond 8/29

Clock Synchronisation There exists a time server receiving signals from a UTC source Cristian s algorithm (Cristian 1989) There is no UTC source available Berkeley s algorithm Exact time does not matter! Lamport s algorithm 9/29

Clock Sync. Algorithm: Cristian's 1. Every computer periodically asks the time server for the current time 2. The server responds ASAP with the current time C UTC 3. The client sets its clock to C UTC 10/29

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 (T 1 -T 0 )/2 If the interrupt handling time, I, is known, (T 1 -T 0 - I)/2 Use series of measurements 11/29

Berkeley Algorithm An algorithm for internal synchronisation 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 12/29

The Berkeley Clock Sync. Algorithm Clocks that are running fast, are slowed down Clocks running slow, jump forward 13/29

Berkeley Algorithm at Work (1) Computers Clock Reading A (daemon) 3:00 B (left) 2:50 C (right) 3:25 Computers Ahead/Behind A (daemon) 0:00 B (left) -0:10 C (right) +0:25 14/29

Berkeley Algorithm at Work (2) Average time: 3:05 Computers Needed Adjustment A (daemon) +0:05 B (left) +0:15 C (right) -0:20 15/29

Other Clock Sync. 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 synchronise clocks to within a 1-50 msec accuracy 16/29

Network Time Protocol (NTP) Primary servers are connected to UTC sources Secondary servers are synchronised to primary servers Synchronisation subnet - lowest level servers in users computers 1 2 2 3 3 3 17/29

Logical Clocks Synchronisation based on relative time Note that (with this mechanism) there is no requirement for relative time to have any relation to the real time What s important is that the processes in the Distributed System agree on the ordering in which certain events occur Such clocks are referred to as Logical Clocks 18/29

What Can Go Wrong-2 Updating a replicated database Even if the clock is synchronised, due to network delays, the updates may come in different order Whoops! 19/29

Lamport s Logical Clocks First point: if two processes do not interact, then their clocks do not need to be synchronised they can operate concurrently without fear of interfering with each other. Second (critical) point: it does not matter that two processes share a common notion of what the real current time is. What does matter is that the processes have some agreement on the order in which certain events occur. Lamport used these two observations to define the happened-before relation (also often referred to within the context of Lamport s Timestamps). 20/29

The Happened-Before Relation (1) If A and B are events in the same process, and A occurs before B, then we can state that A happened-before B is true Equally, if A is the event of a message being sent by one process, and B is the event of the same message being received by another process, then A happened-before B is also true (Note that a message cannot be received before it is sent, since it takes a finite, nonzero amount of time to arrive and, of course, time is not allowed to run backwards) Also, if A happened-before B and B happened-before C, then it follows that A happened-before C 21/29

The Happened-Before Relation (2) Now, assume three processes are in a DS: A, B and C. All have their own physical clocks A sends a message to B If the time the message was sent (attached to the message) exceeds the time of arrival at B, things are NOT OK (as A happened-before B is not true, and this cannot be allowed as the receipt of a message has to occur after it was sent) 22/29

The Happened-Before Relation (3) The question to ask is: How can some event that happened-before some other event possibly have occurred at a later time?? The answer is: it can t! So, Lamport s solution is to have the receiving process adjust its clock forward to one more than the sending timestamp value. This allows the happened-before relation to hold, and also keeps all the clocks running in a synchronised state. The clocks are all kept in sync relative to each other 23/29

Example of Lamport s Timestamps Lamport s algorithm corrects the clock 24/29

Lamport s Timestamps: Overview It is hard to synchronise time across two systems Every message is timestamped If the local clock disagrees, update the local clock (and always move it forward!) If two systems do not exchange messages, they do not need a common clock If do not communicate, no ordering Is it possible to achieve total ordering of events in the system? 25/29

Totally-Ordered Multicast A multicast operation by which all messages are delivered in the same order to each receiver Solution: Each message is timestamped with the current (logical) time of its sender. (Copies of) multicast messages are sent to the sender. Assume all messages sent by one sender are received in the order they were sent and that no messages are lost. 26/29

Protocol Receiving process puts a message into a local queue ordered according to the timestamp. The receiver multicasts an ACK to all other processes. the timestamp of the received message is lower than the timestamp of the ACK. All processes will eventually have the same copy of the local queue consistent global ordering. Message is delivered to applications only when It is at head of queue It has been acknowledged by all involved processes 27/29

Total Multicast at Work Message m1 is sent by client 1 and message m2 is sent by client 2. (m1 and m2 are time stamped s.t. m1 ~ m2) server A receives m1, m2 and server B receives m2, m1 servers A and B multicast the acknowledgements including to themselves. Server A will wait for the acknowledgement from server B for both m1 and m2 before handing them to its application. Server B will wait for the acknowledgement from server A for both m1 and m2 before handing them to its application Both servers order the messages according to the time stamps of the messages and execute. 28/29

Applications of Lamport s Timestamps Vector Timestamps (to capture causality) Global state Local state of each process + messages in transit Termination detection Consult the book (if you want) 29/29