When two replicas accept writes to the same key independently, how do you know whether one write happened after the other or whether they conflict? Physical timestamps can’t be trusted across machines. Vector clocks answer the question exactly.
Each replica keeps a counter. A vector clock is a map from replica ID to counter, attached to each version of a value.
{A:2, B:1} becomes {A:3, B:1}.Example: {A:3, B:1} and {A:2, B:2} are concurrent; A and B each updated without seeing the other’s change.
Clocks grow with the number of writers; systems use the coordinating server’s ID rather than the client’s, and prune old entries. Lamport timestamps are a single counter: they give a total order consistent with causality but can’t detect concurrency, which is the reason to use vector clocks.
Disclosure: I’m on the team behind Linkjob AI (https://www.linkjob.ai/), an AI assistant for technical interviews.