A common follow-up in distributed-systems interviews goes like this: "Two services write to the same record and each stamps the write with its local time. Which write wins?" The answer that loses points is "the one with the later timestamp". Here is how to give a better one.
Every machine's clock drifts. NTP keeps drift small, but small is still tens of milliseconds on a good day and seconds on a bad one (a VM paused for live migration, a leap-second smear, an NTP server that went away). If server A's clock runs 80 ms fast, a write A makes after a write from B can still carry an earlier timestamp. "Last write wins" by wall clock silently drops data.
Say this out loud in the interview: physical timestamps can tell you roughly when, but not reliably in what order.
Leslie Lamport's logical clock gives every event a counter so that if event a could have caused event b, then L(a) < L(b).
on local event: counter += 1 on send(msg): counter += 1; msg.ts = counter on receive(msg): counter = max(counter, msg.ts) + 1 tie-break: compare (counter, node_id)
That tie-break gives a total order every node agrees on, which is enough for things like a replicated log or deciding who holds a lock in a simple mutual-exclusion protocol.
The implication only runs one way. L(a) < L(b) does not prove that a happened before b; the two events might be concurrent. If you need to detect concurrency (say, to keep both versions of a shopping cart and merge them), you need vector clocks: one counter per node, compared element-wise. If every entry of V(a) is ≤ V(b), a happened before b; if neither dominates, they are concurrent.
Hybrid Logical Clocks (HLC) combine a physical timestamp with a logical counter. They stay close to wall time (handy for "show me writes from the last hour") while still respecting causality. CockroachDB uses them; Google Spanner goes the other way and bounds clock uncertainty with TrueTime, waiting out the uncertainty window before committing.
Try explaining, without notes, why a key-value store using last-write-wins by wall clock can lose a user's update during a network partition, and what you would change. If you can do it in under two minutes, you are ready for the follow-up questions.
Disclosure: I work on Linkjob AI, an AI interview assistant. This note is from our system-design interview prep material.