Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

11/24/23, 10:40 PM Event Ordering in Distributed System - GeeksforGeeks

Aptitude Engineering Mathematics Discrete Mathematics Operating System Courses @30% Off DBMS Computer Networks Digital Logic and De

Event Ordering in Distributed System


Read Discuss Courses

In this article, we will look at how we can analyze the ordering of events in a distributed system. As we know a
distributed system is a collection of processes that are separated in space and which can communicate with
each other only by exchanging messages this could be processed on separate computers or it could even be
multiple processes within the same computer.

A defining characteristic is that the delay of transmitting a message is not negligible compared to the time
between events in a single process. There is a fundamental limitation when it comes to ordering events in a
distributed system and that is sometimes it is simply not possible to tell if one event occurred before another
one if you take the complete set of events within a distributed system.

We can only at best define a partial ordering within those events or an intuitive understanding of the ordering of
events is naturally associated with the time at which events occur.

However, in a distributed system we cannot count on physical clocks even if the computers themselves have
physical clocks, because two clocks on two different systems can never be perfectly synchronized they will
always, in reality, be some drift between any two physical clocks.

So, mostly physical time is ignored when it comes to ordering events within a distributed system, events are
only observable within a system.

Now observable events are primarily sending and receiving of messages.

We are assuming that a single process is completely sequential in that we can take all the events within a
single process and totally order them. So that we get the exact sequence in which those events occurred within
that process.

An event is simply the sending or receiving of a message.


Now, partial ordering of events can be denoted by “⇢”, and we can define it as if – we have two events and
be within the same process and a comes before b then a ⇢ b i.e.; a happened before b.
Now, if two processes are communicating with each other a is the sending of a message and b is the receipt
of that message by another process then we define an as happening before b.
Lastly, we have a transitive property which says if a happened before b and b happened before c then a
happened before c as well, a⇢b and b⇢ c then a⇢ c.
Since this is a partial ordering it could very well happen that for two events a and b neither happened before
the other we simply cannot tell by looking at the observable events in the system and in that case we call a
and b to have happened concurrently.

P, Q, R are the process and each dot in the line denotes the events, the curve lines denote messages being
sent between processes from this representation we can see relate p1 and r4 and we can say that p1
happened before r4 because p1 sent a message to Q and that was event q2 we move forward in time within
the process Q we send a message to process R which was received over here at r3. So, we can say p1
happens before r4. and r2, q6 are concurrent as they cannot causally affect one another.
Happened before relation is an irreflexive partial ordering on the set of all events happening in the system
i.e.; (a⇢ a) is not true for any event a.

https://www.geeksforgeeks.org/event-ordering-in-distributed-system/?ref=lbp 1/4
11/24/23, 10:40 PM Event Ordering in Distributed System - GeeksforGeeks

This relates back to Einstein’s general theory of relativity where events are ordered in terms of messages
that could possibly be sent.

Logical Clocks:

A logical clock is a way of assigning a number to an event where that number can be thought of as the time at
which the event occurred and the notation we use here is Ci<a> of an event a, where C is used to denote Clock.
These numbers are purely logical they do not have any relationship to physical time

Conditions For logical clocks:

If a happens before b the logical time of a should be lesser than the logical time of b of a process Pi
a⇢ b then C<a><C<b>
If a is the sending message by process Pi and b is the receipt of that message by Pj the
Ci<a><Cj<b>.
The logical clock is associated with timestamps.

So given these conditions, We define a clock function within a process by simply incrementing the process’s
own clock as we go from event to event i.e.; Each process Pi increments Ci between any two successive events.

So, now we have a partial ordering of the events within a distributed system and we have a way to assign
numbers to those events such that we can construct logical clocks out of them.

Unlock the Power of Placement Preparation!


Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation Course is the ultimate
guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview
triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation course.

Last Updated : 04 Mar, 2022 13

Similar Reads
Causal Ordering of Messages in Distributed Distributed System - Thrashing in Distributed
System Shared Memory

Distributed System - Types of Distributed Distributed Consensus in Distributed


Deadlock Systems

What is Scalable System in Distributed Design Principles of Distributed File System


System?

Mutual exclusion in distributed system Maekawa’s Algorithm for Mutual Exclusion in


Distributed System

Ricart–Agrawala Algorithm in Mutual Lamport's Algorithm for Mutual Exclusion in


Exclusion in Distributed System Distributed System

Related Tutorials
Cryptography Tutorial Distributed Systems Tutorial

Spring MVC Tutorial Spring Boot Tutorial

Java 8 Features - Complete Tutorial

https://www.geeksforgeeks.org/event-ordering-in-distributed-system/?ref=lbp 2/4

You might also like