Clocks and ordering
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
see why wall-clock time cannot order events across nodes.
Planned topics
- Each machine has its own clock; they drift and are corrected by NTP, sometimes jumping backward.
- Two events with timestamps from different machines cannot be reliably ordered.
- Within one machine use a monotonic clock for durations (
System.nanoTime()), not wall time. - Logical ordering uses counters: Lamport clocks and vector clocks (conceptual).
- Practical choices: order by a single log (Kafka partition) or a database sequence.
Draft outline details
Demonstration
two nodes, one at 10:00:05 and one at 10:00:03, where the later event has the smaller timestamp.
Check your understanding
Which clock measures elapsed time safely?
Show answer
A monotonic clock, System.nanoTime().
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.