What is the logical time?

The logical time in distributed systems is used to maintain the consistent ordering of events. The concept of causality, i.e. the causal precedence relationship, is fundamental for distributed systems. Usually, it is tracked using physical time, but physical clocks are hard to maintain in a distributed system, so logical clocks are used instead. The idea that makes logical clocks different is that these are designed to maintain the information about the order of events rather than pertaining to the same notion of time as the physical clocks.

Rules

A logical clock must specify the following two rules to implement proper functionality:

  • Rule 1 determines how a local process updates its clock when an event occurs.
  • Rule 2 determines how a local process updates its global clock upon receiving a message from another process to update its view of global time.
Lamport clock algorithm

Lamport clock is a simple logical clock implementation. The illustration above shows the working of Lamport clock algorithm. You can find explanation in this article.

Applications

Logical time has many applications in distributed systems.

  • It is used to resolve conflicts, track individual events, and take concurrency measures.
  • Logical time also has its application in debugging distributed systems. With all the information about the causal relationship of events, it is easy to spot which event caused the error.
Copyright ©2024 Educative, Inc. All rights reserved