Clocks and Time
In Distributed Systems, time is important for purposes including time stamping in transactions and synchronization in algorithms.
Clock Skew and Drift Rate
Each process has an internal clock. Clocks between processes on different computers differ.
- Skew: relative difference between two clock values
- Drift Rate: change in skew from a perfect reference clock per unit time (measured by the reference clock)
- System Model#Synchronous System have bound on maximum drift rate
Synchronization
External Synchronization: Synchronize time with an authoritative clock, when accurate timestamps are required
- For a synchronization/accuracy bound
, and for a source of UTC time, for all real times in time interval - All clocks
are accurate to within the bound
Internal Synchronization: Synchronize time internally between all processes in a distributed system, when internally comparable timestamps are required
- For a synchronization/accuracy bound
, for all real times in time interval during the time interval - All clocks agree within the bound D
If all clocks in a system are externally synchronized, they are also internally synchronized.
Clocks that are internally synchronized are not necessarily externally synchronized (since they may drift collectively from an external source of time).
If all clocks in a system are externally synchronized within a bound of
, the bound on their skew relative to one another is .
Synchronization in Synchronous Systems
What time

Let
- If
: - If
: - If
: - If
:
Synchronization in Asynchronous Systems
What time
Cristian Algorithm
The use of a time server, connected to a device that receives signals from a source of UTC, to synchronize computers externally. Upon request, the server process
- Client measures the round trip time
- This is the client assuming its one-way delay from server is
- This is the client assuming its one-way delay from server is

Improve accuracy by sending multiple spaced requests and using response with smallest
.
Handling Failure:
- Use multiple synchronized time servers in case of failure.
Handling Faulty Processes:
- Cannot handle faulty time servers.
Berkeley Algorithm
Only supports Internal #Synchronization. An coordinator computer is chosen as leader
- Server periodically polls clients "what time do you think it is?"
- Each client responds with its local time
- Server uses #Cristian Algorithm to estimate local time at each client
- Average all local times (including its own) -- use as updated time
- Send the offset (amount by which each clock needs adjustment)

Handling Faulty Processes:
- Only uses timestamps within some thresholds of each other
Handling Server Failure:
- Detect the failure and elect a new leader
Network Time Protocol
NTP defines an architecture for time service over the Internet for synchronizing to UTC, it has:
- Hierarchical structure for scalability
- Multiple lower strata servers for robustness
- Authentication mechanisms for security
- Statistical techniques for better accuracy
The structure:
- Primary servers are connected directly to a time source such as a radio clock receiving UTC
- Secondary servers are synchronized with primary servers, third with second, etc.
- Each level is a strata
- The leaf servers execute in users' workstations

Ways that NTP servers synchronize with one another:
- Servers multicast timestamps within a LAN, clients adjust time assuming a small delay
(Low accuracy) - Procedure Call (#Cristian Algorithm)
(Higher accuracy) - Symmetric Mode used to synchronize lower strata servers
(Highest accuracy)
Symmetric Mode
Takes into consideration of non-consecutive messages.
Suppose:
and are actual transmission times for and (unknown) is the true offset of clock B relative to clock A (unknown)
We want to estimate:
the offset between the two clocks the accuracy of

We have:
Assuming symmetric