Intermediate Topic 20 of 51 Distributed Systems & Cloud
Logical Clocks
Lamport and vector clocks ordering events without wall time.
How it works
Logical clocks order events in a distributed system without relying on physical time. Lamport clocks keep a counter at each process, increment it on each event and set it to the maximum of local and received timestamps plus one on receipt, ensuring that if event a happens before b, then timestamp(a) is less than timestamp(b), though the reverse does not hold. Vector clocks keep a counter per process and can detect whether events are causally ordered or concurrent. Hybrid logical clocks combine physical time with logical counters.
Where it is used
Distributed databases such as Dynamo and Riak, conflict detection in replicated data, debugging and tracing, and causally consistent messaging use logical clocks.
Common pitfall
Vector clocks grow with the number of processes, which is costly for large systems, requiring pruning or dotted version vectors. Lamport timestamps cannot tell concurrent events apart. Comparing timestamps incorrectly leads to wrong conflict resolution. Define clearly what ordering the application needs and break ties consistently using process IDs.
Where it fits in the course
Logical Clocks is topic 20 of 51 in Distributed Systems & Cloud, rated Intermediate. It follows Clock Synchronization. The next topic is Consensus Problem.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Distributed Systems & Cloud quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Distributed Systems & Cloud quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Logical Clocks?
Where do people use Logical Clocks?
What is the most common mistake with Logical Clocks?
What should I learn before this topic?
How can I practice it?
Is Logical Clocks hard to learn?
How long does it take to learn Logical Clocks?
Which topics are related to Logical Clocks?
What should I study after Logical Clocks?
Related topics
- Clock Synchronization (Distributed Systems & Cloud)
- Consensus Problem (Distributed Systems & Cloud)
- Consistency Models (Distributed Systems & Cloud)
- Paxos (Distributed Systems & Cloud)