0% found this document useful (0 votes)
112 views34 pages

Unit 2 Part 1

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 34

CS 3551 DISTRIBUTED

COMPUTING
Physical clock synchronization: NTP
● Need of Knowing Time:
○ The time of the day at which an event happened on a specific machine in the network.
○ The time interval between two events that happened on different machines in the network.
○ The relative ordering of events that happened on different machines in the network.
● Need for synchronization
○ In database systems, the order in which processes perform updates on a database is
important to ensure a consistent, correct view of the database.To ensure the right ordering of
events, a common notion of time between co-operating processes becomes imperative.
○ Improves the performance of distributed algorithms by replacing communication with local
computation.
○ Distributed protocols use timeouts, and their performance depends on how well physically
dispersed processors are time-synchronized. Design of such applications is simplified when
clocks are synchronized.
● Clock synchronization is the process of ensuring that physically distributed
processors have a common notion of time. It has a significant effect on many
problems like secure systems, fault diagnosis and recovery, scheduled
operations, database systems, and real-world clock values.
Definitions
Different Clocks
Offset Delay Estimation using Network Transmission Protocol

● In practice, a source node cannot accurately estimate the local time on the
target node due to varying message or network delays between the nodes.
● This protocol employs a very common practice of performing several trials
and chooses the trial with the minimum delay.
● The design of NTP involves a hierarchical tree of time servers.
○ The primary server at the root synchronizes with the UTC.
○ The next level contains secondary servers, which act as a backup to the primary server.
○ At the lowest level is the synchronization subnet which has the clients.
network delay
NTP Synch Protocol

offset

b(e)=a(e)-0
a(e)=b(e)+o

delay
CS 3551 DISTRIBUTED
COMPUTING
What is physical clock?

● A physical clock in a system refers to a hardware-based timekeeping device


that tracks the passage of time based on a stable oscillating signal, typically
provided by a quartz crystal.
● It provides a reference for measuring the duration between events, scheduling
tasks, and maintaining synchronization within the system.
Need of Clock
Why not physical clocks in distributed system?
Search Engine
So what is the solution? Logical Clock
Read Input Search Display

1. In distributed computing, logical time refers to a mechanism used to establish


an ordering of events that occur across different nodes or processes in a
distributed system.
2. It provides a way to reason about the causal relationships between events,
even in the absence of a globally consistent physical time.
3. Logical time is crucial for coordinating activities, maintaining consistency, and
enabling the implementation of various distributed algorithms and protocols.
4. It also ensures proper order of events.
5. Every event is assigned a timestamp and the causality relation between
events can be generally inferred from their timestamps.
6. The timestamps assigned to events obey the fundamental monotonicity
property; that is, if an event a causally affects an event b, then the timestamp
of a is smaller than the timestamp of b
Methods of Representing Logical Time
1. Lamport’s scalar clocks, the time is represented by non-negative integers
2. The time is represented by a vector of non-negative integers
3. The time is represented as a matrix of non-negative integers
What is Causal Relationship?
1. Brush -> Tea
2. Bike Start -> Bike Drive
3. Cook -> Eat

● A causal relationship refers to a cause-and-effect connection between two or


more events or variables, where one event (the cause) brings about another
event (the effect)
● It signifies that the occurrence of one event leads to or affects the occurrence
of another event.
Example Event Diagram cause
effect

Faculty

HOD

Exam Dept
Benefits of Causal Precedence
CS 3551 DISTRIBUTED
COMPUTING
Framework for System of Logical Clocks
time domain (non negativ

● A system of logical clocks consists of a time domain T and a logical clock C.


● The logical clock C is a function that maps an event e in a distributed system
to an element in the time domain T, denoted as C(e) and called the timestamp
of e, and is defined as follows:

each events cause and effect

consistent
Implementing Logical Clocks
Every process needs data structure(store logical time)+algorithms(updation)

updation
Scalar Time - non-negative integer

logical clock

exclusively used at receivr end


logiacl time gets incremented befoe events occur

from sender to receiver the mssage is send with


ATM clock value

to compute this take max value


Server

doesn't take
Properties of Scalar Time
1. Consistency
2. Total Ordering
dif timestamps execute as same order
a. Case 1
b. Case 2 repeat values

3. Event Counting the timestamp for both are same,


see the event id first and execute the
4. No strong consistency ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
size of array=no of processes

Vector Time vti[i] - The process’s own logical time


vtj[j] - Info on j’s process local time

P1

P2

P3
Rules

P1

P2
Properties on Comparing two Timestamps
Properties
1. Isomorphism

2. Strong Consistency - The system of vector clocks is strongly consistent; thus,


by examining the vector timestamp of two events, we can determine if the
events are causally related.
3. Event Counting -
Size of Vectors
● A vector clock provides the latest known local time at each other process. If
this information in the clock is to be used to explicitly track the progress at
every other process, then a vector clock of size n is necessary.
● A popular use of vector clocks is to determine the causality between a pair of
events.

You might also like