Vector Clock in Distributed System clock design vector.
Vector Clock in Distributed System clock design vector.
Contents
- 1 🔹 Vector Clock in Distributed Systems – Clock Design & Concept
- 2 ✅ What is a Vector Clock?
- 3 🧭 Why is it Needed?
- 4 📐 Vector Clock Design (Structure)
- 5 🔧 How Vector Clocks Work (Rules):
- 6 📊 Example:
- 7 🧠 Interpretation of Vector Clocks:
- 8 📝 Benefits of Vector Clocks:
- 9 ⚖️ Limitations:
- 10 Vector Clock in Distributed System clock design vector.
- 11 LOGICAL AND VECTOR CLOCKS USED IN …
- 12 A Practical Tour of Vector Clock Systems.
- 13 Clocks in Distributed System
- 14 Chapter 3: Logical Time
🔹 Vector Clock in Distributed Systems – Clock Design & Concept
✅ What is a Vector Clock?
A Vector Clock is a logical clock mechanism used in distributed systems to capture causal relationships between events — especially to determine whether one event happened before another (→ “happened-before” relation).
Unlike Lamport clocks (which can only show if events are ordered or concurrent), vector clocks can precisely track causality.
🧭 Why is it Needed?
In distributed systems, due to the absence of a global clock:
- It’s hard to know the actual order of events.
- Vector clocks help track causal dependencies among processes.
📐 Vector Clock Design (Structure)
Each process in a distributed system maintains a vector of integers — one entry for every process in the system.
Example:
For a system with 3 processes P1, P2, P3, each process maintains a vector clock like:
VC(P1) = [v1, v2, v3]
Where:
v1
: P1’s own clockv2
: P1’s knowledge of P2’s clockv3
: P1’s knowledge of P3’s clock
🔧 How Vector Clocks Work (Rules):
- Initialization:
- Every process starts with vector
[0, 0, ..., 0]
- Every process starts with vector
- Local Event:
- A process increments its own clock.
VC[i] = VC[i] + 1
- Send Message:
- Increment local clock.
- Send the entire vector along with the message.
- Receive Message:
- Increment own clock.
- Take the element-wise maximum of the received vector and own vector.
VC[i] = max(VC[i], received VC[i]) for all i
📊 Example:
Let’s assume:
P1
sends a message toP2
- VC(P1) before sending:
[2,0,0]
P1
sends message →[3,0,0]
to P2
P2
receives message when its clock was [1,2,0]
Now it computes:
VC(P2) = max([1,2,0], [3,0,0]) → [3,2,0]
Then increments its own component → [3,3,0]
🧠 Interpretation of Vector Clocks:
For two events with vector clocks VC1
and VC2
:
- VC1 < VC2 → VC1 happened before VC2
- VC1 || VC2 → Events are concurrent (no causal relationship)
📝 Benefits of Vector Clocks:
- Captures causality precisely.
- Helps in version control, conflict resolution, and event ordering.
- Used in distributed databases, Git, blockchains, etc.
⚖️ Limitations:
- Requires O(n) space and communication overhead (where n = number of processes).
- Not scalable for large systems.
Would you like a diagram, visual animation, or real-world application (like in DynamoDB or Git)? I can also provide this in Hindi if you prefer.