educative.io

Educative

Vector Clock: How Are The Events shown in the sequence of slides? How Are The Arrows Flowing?

It is not clear for me how the events are happening or are connected in the example. The description of the Vector clock says that it will have the following format:

[vector-clock][worker-id]

And basically it is the description of such format:

  • Sign bit: A single bit is assigned as a sign bit, and its value will always be zero.
  • Vector clock: This is 53 bits and the counters of each node.
  • Worker number: This is 10 bits. It gives us 2^{10} = 1,024 worker IDs.

That being said, in Node A, Node B and Node C, I’m assuming there is some relationship in the events and that is the reason the arrows are going from one side to the other. But I don’t understand when and how the arrows are jumping.

Why the arrows in slide 3 and 5 for example, are sort of “in the middle of” something? and also how is A1and B1 connected by the arrow? but B2 is not “connected” by an arrow to C2, C3?

Also how is the [x,y,z] format of the vector clock changing? Why there are cases where no new ID is needed to be generated?


Course: Grokking Modern System Design Interview for Engineers & Managers - Learn Interactively
Lesson: Unique IDs with Causality - Grokking Modern System Design Interview for Engineers & Managers

2 Likes

I will answer to myself as I have understood now.

  • Arrows are just linking non concurrent events. Concurrent events are not linked by arrows between Nodes.
  • the format of the Vector Clock is the array [n1,n2,n3) where each position of the array corresponds to the event that happened in node 1,2 or 3, and it is increased every time an event happens for that node.
  • If it is a non concurrent event, we will see the arrow linking those events, and carrying the counter for the nodes related to the event (and increasing the counter for the node pointed out by the arrow (basically where the arrow is landing).

If somebody thinks different, let me know.


Course: Grokking Modern System Design Interview for Engineers & Managers - Learn Interactively
Lesson: Unique IDs with Causality - Grokking Modern System Design Interview for Engineers & Managers

1 Like

I am not understanding it either. How would the system know which events are concurrent or not? I mean how do the the individual nodes know when to communicate with each other to update their clocks?