CS505: Distributed Systems

Similar documents
Time. Today. l Physical clocks l Logical clocks

Time. To do. q Physical clocks q Logical clocks

CS505: Distributed Systems

Agreement. Today. l Coordination and agreement in group communication. l Consensus

Distributed systems Lecture 4: Clock synchronisation; logical clocks. Dr Robert N. M. Watson

Clock Synchronization

Chapter 11 Time and Global States

Time in Distributed Systems: Clocks and Ordering of Events

Slides for Chapter 14: Time and Global States

Absence of Global Clock

7680: Distributed Systems

Distributed Computing. Synchronization. Dr. Yingwu Zhu

Clocks in Asynchronous Systems

DISTRIBUTED COMPUTER SYSTEMS

Time is an important issue in DS

Distributed Systems 8L for Part IB

416 Distributed Systems. Time Synchronization (Part 2: Lamport and vector clocks) Jan 27, 2017

Distributed Systems Principles and Paradigms. Chapter 06: Synchronization

Distributed Systems Principles and Paradigms

CS 425 / ECE 428 Distributed Systems Fall Indranil Gupta (Indy) Oct. 5, 2017 Lecture 12: Time and Ordering All slides IG

Our Problem. Model. Clock Synchronization. Global Predicate Detection and Event Ordering

Causality and physical time

CS 347 Parallel and Distributed Data Processing

Logical Time. 1. Introduction 2. Clock and Events 3. Logical (Lamport) Clocks 4. Vector Clocks 5. Efficient Implementation

Distributed Systems. Time, Clocks, and Ordering of Events

CptS 464/564 Fall Prof. Dave Bakken. Cpt. S 464/564 Lecture January 26, 2014

Cuts. Cuts. Consistent cuts and consistent global states. Global states and cuts. A cut C is a subset of the global history of H

Time, Clocks, and the Ordering of Events in a Distributed System

Recap. CS514: Intermediate Course in Operating Systems. What time is it? This week. Reminder: Lamport s approach. But what does time mean?

Clock Synchronization

Consistent Global States of Distributed Systems: Fundamental Concepts and Mechanisms. CS 249 Project Fall 2005 Wing Wong

Distributed Systems Fundamentals

Figure 10.1 Skew between computer clocks in a distributed system

Distributed Algorithms Time, clocks and the ordering of events

A subtle problem. An obvious problem. An obvious problem. An obvious problem. No!

Today. Vector Clocks and Distributed Snapshots. Motivation: Distributed discussion board. Distributed discussion board. 1. Logical Time: Vector clocks

Distributed Mutual Exclusion Based on Causal Ordering

Distributed Systems. Time, clocks, and Ordering of events. Rik Sarkar. University of Edinburgh Spring 2018

CS5412: REPLICATION, CONSISTENCY AND CLOCKS

Time. Lakshmi Ganesh. (slides borrowed from Maya Haridasan, Michael George)

Agreement Protocols. CS60002: Distributed Systems. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur

arxiv: v1 [cs.dc] 22 Oct 2018

Distributed Systems. 06. Logical clocks. Paul Krzyzanowski. Rutgers University. Fall 2017

Causality and Time. The Happens-Before Relation

Early consensus in an asynchronous system with a weak failure detector*

Distributed Systems Time and Global State

Coordination. Failures and Consensus. Consensus. Consensus. Overview. Properties for Correct Consensus. Variant I: Consensus (C) P 1. v 1.

Byzantine Agreement. Gábor Mészáros. CEU Budapest, Hungary

Distributed Algorithms (CAS 769) Dr. Borzoo Bonakdarpour

TTA and PALS: Formally Verified Design Patterns for Distributed Cyber-Physical

1 Introduction During the execution of a distributed computation, processes exchange information via messages. The message exchange establishes causal

MAD. Models & Algorithms for Distributed systems -- 2/5 -- download slides at

Do we have a quorum?

1.4 Equivalence Relations and Partitions

1 Introduction During the execution of a distributed computation, processes exchange information via messages. The message exchange establishes causal

Genuine atomic multicast in asynchronous distributed systems

A VP-Accordant Checkpointing Protocol Preventing Useless Checkpoints

Accurate Event Composition

Chapter 7 HYPOTHESIS-BASED INVESTIGATION OF DIGITAL TIMESTAMPS. 1. Introduction. Svein Willassen

Abstract. The paper considers the problem of implementing \Virtually. system. Virtually Synchronous Communication was rst introduced

14 Equivalence Relations

Byzantine Agreement. Gábor Mészáros. Tatracrypt 2012, July 2 4 Smolenice, Slovakia. CEU Budapest, Hungary

I Can t Believe It s Not Causal! Scalable Causal Consistency with No Slowdown Cascades

S1 S2. checkpoint. m m2 m3 m4. checkpoint P checkpoint. P m5 P

Failure detectors Introduction CHAPTER

Distributed Algorithms

Verification of clock synchronization algorithm (Original Welch-Lynch algorithm and adaptation to TTA)

Implementing Uniform Reliable Broadcast with Binary Consensus in Systems with Fair-Lossy Links

Dynamic Group Communication

DES. 4. Petri Nets. Introduction. Different Classes of Petri Net. Petri net properties. Analysis of Petri net models

TSCCLOCK: A LOW COST, ROBUST, ACCURATE SOFTWARE CLOCK FOR NETWORKED COMPUTERS

CS505: Distributed Systems

Causal Consistency for Geo-Replicated Cloud Storage under Partial Replication

Gradient Clock Synchronization

AGREEMENT PROBLEMS (1) Agreement problems arise in many practical applications:

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Consensus. One Reason: Impossibility of Consensus. Let s Consider This

Approximate Synchrony: An Abstraction for Distributed Time-Synchronized Systems

Lecture 8: Time & Clocks. CDK: Sections TVS: Sections

Integrating External and Internal Clock Synchronization. Christof Fetzer and Flaviu Cristian. Department of Computer Science & Engineering

Snapshots. Chandy-Lamport Algorithm for the determination of consistent global states <$1000, 0> <$50, 2000> mark. (order 10, $100) mark

A Communication-Induced Checkpointing Protocol that Ensures Rollback-Dependency Trackability

On the Growth of the Prime Numbers Based Encoded Vector Clock

Generic Broadcast. 1 Introduction

Simulation of the IEEE 1588 Precision Time Protocol in OMNeT++

cs/ee/ids 143 Communication Networks

Rollback-Dependency Trackability: A Minimal Characterization and Its Protocol

Using Happens-Before Relationship to debug MPI non-determinism. Anh Vo and Alan Humphrey

Finally the Weakest Failure Detector for Non-Blocking Atomic Commit

Design of a Sliding Window over Asynchronous Event Streams

Seeking Fastness in Multi-Writer Multiple- Reader Atomic Register Implementations

Model Checking of Fault-Tolerant Distributed Algorithms

Efficient Dependency Tracking for Relevant Events in Concurrent Systems

Reading 11 : Relations and Functions

EECS Components and Design Techniques for Digital Systems. FSMs 9/11/2007

6.852: Distributed Algorithms Fall, Class 10

CS505: Distributed Systems

CSC Discrete Math I, Spring Relations

The main limitation of the concept of a. function

Lecture 13: Sequential Circuits, FSM

Learning from the Past for Resolving Dilemmas of Asynchrony

Transcription:

Department of Computer Science CS505: Distributed Systems Lecture 5: Time in Distributed Systems

Overview Time and Synchronization Logical Clocks Vector Clocks

Distributed Systems Asynchronous systems: no bounds On communication delays On relative processing speeds But sometimes we need information on what happened when Consistent view of distributed application

Examples Distributed database transaction journaling and logging Stock market buy and sell orders Secure document timestamps (with cryptographic certification) Aviation traffic control and position reporting

Sensor Networks Communication is expensive (even if a node does not have any data to receive, just listening consumes power) Power is limited Synchronization is important because Nodes can sleep and save battery Communication may be avoided

Ordering of Events Order of events, particularly causality helps in reasoning or analyzing a system Single process Each event has a timestamp, causality relation between events is given by time Distributed processes Many events generated at different processes, concurrent, related? Time is essential for ordering events in a distributed system Physical time: local clock, global clock Logical time: partial ordering, total ordering

Using Real Clocks Global clock Processes have access to a central global clock, each event will carry a timestamp Local clock Each process has its own clock What if the clocks are not synchronized What if events happened at the same time?

Synchronizing Physical Clocks External synchronization Consider the source S and the synchronization bound B > 0, then none of the clocks drift with more than B from S, at any time Internal synchronization Consider the synchronization bound B > 0, then at any time, the difference between any two clocks is within B

Algorithms for Clock Synchronization Cristian s algorithm Uses a time server to synchronize clocks Clients ask the time server for time and adjust their clock based on response RTT estimated by the client: T send - T receive T client = T server + (RTT / 2 )

Algorithms for Clock Synchronization Berkeley algorithm Uses elected master to synchronize The master obtains the local time from all machines, adjusts times received for RTT & latency, averages times, and tells each machine how to adjust In some systems multiple time servers are used Time is more accurate, but still drifts

From Theory to Practice Synchronize computers across several networks? NTP (network time protocol) is a protocol designed to synchronize the clocks of computers over a network NTP version 3 is an internet draft standard, formalized in RFC 1305 NTP version 4 is a significant revision of the NTP standard, current development version Nominal accuracies of low tens of milliseconds on WANs, submilliseconds on LANs, and submicroseconds using a precision time source such as a cesium oscillator or GPS receiver Details www.eecis.udel.edu/~mills/database/brief/overview/overview.ppt

NTP Capsule Summary Primary (stratum 1) servers synchronize to national time standards via radio, satellite and modem Secondary (stratum 2,...) servers and clients synchronize to primary servers via hierarchical subnet Clients and servers operate in master/slave, symmetric and multicast modes with or w/o cryptographic authentication Reliability assured by redundant servers and diverse network paths Engineered algorithms reduce jitter, mitigate multiple sources and avoid improperly operating servers System clock is disciplined in time and frequency using an adaptive algorithm responsive to network time jitter and clock oscillator frequency wander

Overview

From Physical Clocks to Logical Clocks Synchronized clocks are great if we have them, but Do we need the real time anyway? In distributed systems we often only care about relative time

``Happened Before p 1 p 2 p 3 p 4 a b if either events a and b take place at the same process and a occurs before b a is a send(m) event at p i and b is receive(m) event at p k, p i p k exists c : a c and c b

Lamport (Logical) Clocks Each process maintains its own clock C i (a counter) For any events a and b at process p i if a b then C i (a) < C i (b) Implementation Each process p i increments C i between any successive events On send(m) event a, attach local clock T m to message m T m = C i (a) On receive(m) process p k sets C k to C k = max(c k,t m ) + 1

Example p 1 2 3 6 7 8 p 2 1 7 8 p 3 4 5 6 9

Total Order? Logical Clocks provide partial order Often total order is required E.g., delivery of requests/messages by replicas TO can be obtained by breaking ties E.g., use ordered process identifiers If a is event in p i and b is event in p k then a b C i (a) < C k (b) or iff C i (a) = C k (b) and p i < p k

Reminder: Partial and Total Order Definition: A relation R over a set S is a partial order iff for each a, b, and c in S arb bra a = b (antisymmetric) arb brc arc (transitive) ara (reflexive) Definition: A relation R over a set S is a total order if for each distinct a and b in S R is antisymmetric R is transitive either arb or bra (totality)

Concurrent Events Concurrent events a and b are concurrent if neither causally influences the other Logical clocks assign order to events that are causally independent, in other words events that are causally independent appear as if they happened in a certain order a b implies C(a) < C(b) C(a) < C(b) implies b a C(a) < C(b) does not imply a b!!! We need higher resilience

Vector Clocks Each process maintains vector V i initially [0, 0,...] When p i executes an event, it increments V i [ i ] When p i does send(m) to p j, m piggybacks V i When p i does receive(m) from p k V i [i] = V i [i] + 1 V i = sup(v i, m.v), where sup(v 1, V 2 ) = V s.t. j: 1 j n, V[j] = max(v 1 [j], V 2 [j])

Vector Clocks: Example 0 0 0 p 1 1 1 0 2 1 0 3 1 2 4 1 2 5 1 2 0 0 0 p 2 0 1 0 2 2 3 4 3 3 0 0 0 p 3 2 1 1 2 1 2 2 1 3 5 1 4

How to Order with Vector Clocks Given two events a and b, a b iff b has a counter value for the process in which a occurred greater than or equal to the value of that process at event a inclusive, and a has a counter value for the process in which b occurred strictly less than the value of that process at event b inclusive Formally a b i: 1 i n: V(a)[i] V(b)[i] j: 1 j n: V(a)[j] < V(b)[j] b a i: 1 i n: V(b)[i] < V(a)[i] j: 1 j n: V(a)[j] < V(b)[j]

Cuts There is no outside observer that can look at the system and detect problems, for example a deadlock Cut: n-vector (c 1, c n ) of positive integers c i represents cut event on p i ; c i = V i [i] at that point Consistent cut: if for all i, j, (c i + 1) event at process p i did not happen before c j event at p j p 1 1 2 3 4 p 2 1 2 3 4 Consistent cut Inconsistent cut

Vector Clocks and Consistent Cuts A consistent cut K is a subset of events in E s.t. e in K, e e e in K c i event of cut K on p i (or last event on p i in K) Global time of cut K is T = sup(v(c 1 ),, V(c n )) Theorem K is consistent T = (V(c 1 )[1],, V(c n )[n])

Why? ( ) For any time diagram with a consistent cut consisting of cutevents c 1,, c n, there is an equivalent time diagram where c 1, c n occur simultaneously (in real time), i.e., where the cut line forms a straight vertical line Any message has a delay At any point in (real) time, V i [i] = max(v k [i]) k i: 1 k n (, contradict.) If K is inconsistent then some p i sends message m after c i, received by p k before c k As a consequence c i [i] < m.v[i] c k [i]

Constructing A Consistent Cut p i ticks and fixes snapshot time s to V i + (0,, 1, 0) Send s to all processes Waits for acknowledgements from all processes p i ticks again (setting V i to s), takes a local snapshot, and broadcasts dummy message to all processes This forces all processes to advance their clocks to a value s Each process takes a local snapshot and sends it to p i when its local clock becomes equal to s or jumps from some value smaller than s to a value larger than s

References Time, Clocks, and The Ordering of Events in Distributed Systems. L. Lamport, CACM 27(7): 558-565, 1978. Virtual Time and Global States of Distributed Systems, F. Mattern, WDPA 89.

Next Time (A Modular Approach to) Fault-tolerant Broadcasts and Related Problems. V. Hadzilacos and S. Toueg, Distributed Systems, 97-145, 1993.