---
title: "Three Clocks are Better than One"
description: "TigerBeetle builds a fault-tolerant \"cluster time\" by measuring clock offsets to peers during keepalive probes."
url: "https://swe.quest/articles/three-clocks-are-better-than-one-10703f0b75ab21bf"
canonical: "https://tigerbeetle.com/blog/2021-08-30-three-clocks-are-better-than-one"
source: "TigerBeetle"
published: "2021-08-30"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 5
tags: ["time-clocks","distributed-systems","linux"]
---

# Three Clocks are Better than One

A post on [TigerBeetle](https://swe.quest/sources/tigerbeetle.md), published 2021-08-30, 5 min read, Deep dive. Original: [https://tigerbeetle.com/blog/2021-08-30-three-clocks-are-better-than-one](https://tigerbeetle.com/blog/2021-08-30-three-clocks-are-better-than-one)

## Summary

TigerBeetle builds a fault-tolerant "cluster time" by measuring clock offsets to peers during keepalive probes. Each offset combines the peer's wall-clock timestamp with half the round-trip time, and the best low-latency samples from windows of up to 20 seconds are fed to Marzullo's algorithm, which yields bounds agreed by a majority of clocks. That lets a server correct its system time when NTP silently fails, or shut down safely if too many clocks are faulty. Elapsed time should be measured with CLOCK\_BOOTTIME rather than CLOCK\_MONOTONIC, which stops counting during system suspend (e.g. VM migration), or CLOCK\_MONOTONIC\_RAW, which exists for NTP to measure oscillator drift.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Time & clocks](https://swe.quest/tags/time-clocks.md) (Distributed systems)
- [Distributed systems](https://swe.quest/tags/distributed-systems.md) (Distributed systems)
- [Linux](https://swe.quest/tags/linux.md) (Infrastructure)

## Prerequisites

- NTP basics ([easy posts on Time & clocks](https://swe.quest/tags/time-clocks.md?difficulty=easy))
- clock drift and skew
- distributed system clusters

## Keywords

TigerBeetle, CLOCK\_BOOTTIME, CLOCK\_MONOTONIC, CLOCK\_MONOTONIC\_RAW, Marzullo's algorithm, NTP, clock\_gettime

## Related posts

- [Tracking Time Without Clock](https://swe.quest/articles/tracking-time-without-clock-7964e27d177f0db1.md): TigerBeetle · 2025-10-21 · Medium · 2 min read · Time & clocks, Testing, Zig, System design
  Instead of threading a full virtualized Clock interface through every component, two lighter patterns often suffice for handling time in reliable systems.
- [Living without atomic clocks: Where CockroachDB and Spanner diverge](https://swe.quest/articles/living-without-atomic-clocks-where-cockroachdb-and-spanner-diverge-d4e6d0cdd53bad94.md): Cockroach Labs · 2022-01-27 · Hard · 10 min read · Consistency models, Time & clocks, Distributed databases, Distributed systems
  CockroachDB borrows Spanner's TrueTime-inspired approach to ordering distributed transactions but replaces atomic-clock-bounded certainty with a looser uncertainty interval and uncertainty restarts.
- [PTP: Timing accuracy and precision for the future of computing](https://swe.quest/articles/ptp-timing-accuracy-and-precision-for-the-future-of-computing-7cb5bf24683b59a5.md): Meta Engineering · 2022-11-21 · Easy · 8 min read · Time & clocks, Datacenters, Networking, Open source
  Meta is rolling out Precision Time Protocol (PTP) across its data centers to replace NTP, moving clock synchronization precision from milliseconds to nanoseconds.
- [Building On-call: Time, timezones, and scheduling](https://swe.quest/articles/building-on-call-time-timezones-and-scheduling-f978980b35f41e6a.md): incident.io · 2024-07-18 · Medium · 11 min read · Time & clocks, Scheduling, Testing, PostgreSQL, Go
  incident.io's on-call scheduler computes who is on shift from rotations with working hours, round-robin handovers and overrides, and getting it right depends on being precise about local time, offsets, IANA timezones, instants and durations.
- [How Precision Time Protocol is being deployed at Meta](https://swe.quest/articles/how-precision-time-protocol-is-being-deployed-at-meta-6d56b79aabe69525.md): Meta Engineering · 2022-11-21 · Hard · 27 min read · Time & clocks, Networking, Datacenters, Hardware, Consistency models
  Meta replaced NTP with Precision Time Protocol across its data centers to get nanosecond-level clock sync.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
