Distributed Systems

Vector Clock a simple explanation

0
(0)

Vector clocks algorithms are used in distributed systems to provide a causally consistent ordering of events but the entire Vector is sent to each process for every message sent, in order to keep the vector clocks in sync.

 

Let’s try to understand mechanism of vector clock.

  • Initially all clocks are zero.
  • Each time a process experiences an internal event, it increments its own logical clock in the vector by one. For instance, upon an event at process i, it updates Vector Clock i = Vector Clock i + 1
  • Each time a process sends a message, it increments its own logical clock in the vector by one and then the message piggybacks a copy of its own vector.
  • Each time a process receives a message, it increments its own logical clock in the vector by one and updates each element in its vector by taking the maximum of the value in its own vector clock and the value in the vector in the received message (for every element)

Let’s try to understand vector clock mechanism with one another explanation.

The rule for incrementing the timestamp for the vector clock is also similar to Lamport’s clock with a small addition to it. The events update the logical timestamp according to the below rules:

  1. Before executing an event, the process i increments the i-th element of its vector clock by 1

2. During a send event, the process i increments the i-th element of its vector clock by 1 and sends the time(Vmsg[1…N]) along with the message.

3. During a receive event, the process i increments the i-th element of its vector clock by 1. For all other processes, it takes the maximum of the corresponding element in the incoming message and its own local vector and sets it as the corresponding element in the local clock itself.

We can use the vector timestamps to verify if two events are either causally related or concurrent. Before that, we will see how two vector timestamps are compared.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments