Reaves.dev

v0.1.0

built using

Phoenix v1.7.12

Time In Distributed Systems

Stephen M. Reaves

::

2023-01-24

Notes about Lesson 3 of CS-7210

Required Reading:

Optional Reading:

Summary

Why do we need time?

Ordering:

Why is measuring time hard in DS?

It’s impossible to know how long network traffic will take

Node clocks are not gauranteed to be synchronized

No gaurantees there won’t be failures

Logical Time

Virtual time measured virtual clocks

Logical Clock can be thought of as a generator of timestamps.

… if an event a causally affects an event b, then the timestamp of a must be smaller than the timestamp of b. [Logical Time]

e1e2C(e1)<C(e2) e_1 \rightarrow e_2 \Rightarrow C(e_1) < C(e_2)

Common Notations

pi p_i generates events ei0,ei1,,eik,eik+1,,ein e_i^0, e_i^1, \dots, e_i^k, e_i^{k+1}, \dots, e_i^n

eikeik+1 e_i^k \rightarrow e_i^{k+1}

Hi H_i := ordered sequence of events in pi p_i

Events

Concurrent Events

Concurrent Events := two events in which neither event happens before the Other

e1e2e2e1e1e2 e_1 \nrightarrow e_2 \land e_2 \nrightarrow e_1 \Rightarrow e_1 || e_2

Lamport’s Scalar Clock

Each node has it’s own implementation of the clock which runs the clock rules to generate timestamps

Nodes only know the value of the timestamp that they computed

Clock Rules

  1. Process imcrements timestamp on successive events
  2. If a process receives a message, the new timestamp is the maximum of the message’s timestamp +1 and the processes original timestamp

Vector Clock

Each process maintains its own view of time at other nodes

Matrix Clock

Each process maintains its view about every other process’ view of the global time

Possible to use garbage collection, since we know all processes know everything that has happened past a certain point.