Lably
Skip to content

Vector clock

Algorithm for partial ordering of events and detecting causality in distributed systems

  • 4 min read
  • 6 chapters

Related on Lably

Through Data structure, Distributed computing and Causality

The clock updates proceed as follows, where VCi denotes the value of the vector clock maintained by process i:

  • Initially all clocks are zero.
  • Each time a process experiences an internal event, it increments its own logical clock in the vector by one. For instance, upon an event at process i, it updates VCi[i]←VCi[i]+1.
  • Each time a process sends a message, it increments its own logical clock in the vector by one (as in the bullet above, but not twice for the same event) then it pairs the message with a copy of its own vector and finally sends the pair.
  • Each time a process receives a message-vector clock pair, it increments its own logical clock in the vector by one and updates each element in its vector by taking the maximum of the value in its own vector clock and the value in the vector in the received pair (for every element). For example, if process Pi receives a message (m,VCj) from Pj, it first increments its own logical clock in the vector by one VCi[i]←VCi[i]+1 and then updates its entire vector by setting VCi[k]←max(VCi[k],VCj[k]),∀k.

History

Lamport originated the idea of logical Lamport clocks in 1978. However, the logical clocks in that paper were scalars, not vectors. The generalization to vector time was developed several times, apparently independently, by different authors in the early 1980s. At least 6 papers contain the concept. The papers canonically cited in reference to vector clocks are Colin Fidge’s and Friedemann Mattern’s 1988 works, as they (independently) established the name "vector clock" and the mathematical properties of vector clocks.

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Computing and communication