Hybrid Logical Clocks (HLC) give distributed databases 64-bit, NTP-compatible timestamps that stay within clock error epsilon of physical wall time while preserving Lamport’s happened-before causality without blocking writes. In their 2014 technical report, Sandeep Kulkarni, Murat Demirbas, Deepak Madeppa, Bharadwaj Avva, and Marcelo Leone bridged logical clocks (which cannot answer wall-time queries) and physical NTP clocks (whose 1 to 100 ms skews and backward jumps invert cause and effect).

Two years earlier, Google Spanner had achieved global snapshot reads using GPS antennas, atomic clocks, and a 2 * epsilon commit-wait delay per write. HLC showed how commodity cloud clusters running standard NTP can support wait-free consistent snapshots by pairing a bounded wall-time tracker l with a tiny causal counter c, a pattern now standard in CockroachDB and YugabyteDB.

  • One-way causality in O(1) space: For any events e and f, e hb f implies (l.e, c.e) < (l.f, c.f) using two integers instead of O(N) vector clocks, while l.f >= pt.f always holds (Theorems 1 and 2).
  • Bounded drift and counter size: Separating l (max pt seen) from c (same-l tie-breaker) bounds drift to |l.f - pt.f| <= epsilon (Corollary 1) and counters to c.f <= N * (epsilon + 1) (Corollary 3).
  • Drop-in 64-bit NTP layout: Ceiling-rounding pt to the top 48 bits (microsecond resolution) leaves 16 bits for c (up to 65,536), reading NTP passively via superposition without modifying host clocks.
  • Tiny counters in AWS clusters: Across 4 to 16 m1.xlarge nodes sending 75,000 to 425,000 wire-speed messages, c = 0 held for 65.56% to 95% of events (max c = 8 on 16 nodes; max l - pt = 0.02 ms across four WAN regions).
Four clock designs tested against HLC’s four requirements
Logical & Vector Clocks
Strong causal guarantees divorced from wall-clock time.
Lamport LC & Vector Clocks (VC)
LC satisfies e hb f => lc.e < lc.f in O(1) space, but cannot query by physical time; VC captures all cuts (<=>) yet requires O(N) space per message.
Physical Time & TrueTime
Human-readable timestamps constrained by synchronization error.
NTP Physical Time (PT) & Spanner TrueTime (TT)
Raw NTP (1 ms LAN, 10 to 100 ms+ WAN, leap-second jumps) can invert causality; TrueTime preserves order only via GPS/atomic clocks plus commit-wait delays.
Hybrid Logical Clock
Combines l (max pt seen) and c (causal tie-breaker).
HLC (l, c) in 64 bits
Guarantees e hb f => (l.e, c.e) < (l.f, c.f), |l - pt| <= epsilon, wait-free writes, and consistent snapshots at (l = t, c = 0).

Problem framing from Kulkarni et al. (2014), Sections 1 through 3.1.

Why the single-scalar naive algorithm drifts forever

Kulkarni and colleagues formalize the HLC problem with four strict requirements (Section 3.1): assign every event e a timestamp such that (1) e hb f implies l.e < l.f, (2) space is O(1) integers updated in O(1) operations, (3) representation space stays bounded (ideally 64 bits), and (4) |l.e - pt.e| remains bounded close to physical time pt.

The most tempting design uses a single integer l.j initialized to 0 and combines Lamport’s rules with max(..., pt.j):

  • On a send or local event: l.j := max(l.j + 1, pt.j)
  • On receiving message m: l.j := max(l.j + 1, l.m + 1, pt.j)

That naive algorithm satisfies requirements 1 and 2, then breaks requirements 3 and 4 immediately. In the paper’s Figure 4 counterexample, node 0 seeds a higher physical clock (10) into a tight messaging loop among nodes 1, 2, and 3 whose physical clocks sit at 0, 1, 2, ... and tick slower than message hops. Each hop forces +1 (11, 12, 13, 14, ...), driving |l - pt| upward without bound even if every node’s physical clock increments between local events.

The root cause is subtle: storing both the maximum physical clock seen so far and per-event +1 increments in one variable erases provenance. Once l hits 15, a node cannot tell whether 15 came from a real pt = 15 somewhere in the cluster or from five fast causal hops starting at pt = 10, so there is never a safe place to reset l without risking a violation of e hb f => l.e < l.f.

HLC solves this with one level of indirection, splitting the timestamp into (l.j, c.j) (Figure 5):

  1. l.j tracks only the highest physical time seen so far: On local or send events, l.j := max(l0.j, pt.j) (dropping + 1). On receive, l.j := max(l0.j, l.m, pt.j). By induction (Theorems 2 and 3), l.f >= pt.f always holds, and whenever l.f > pt.f, some causal ancestor g hb f actually had pt.g = l.f. Under bounded NTP skew |pt.g - pt.f| <= epsilon, Corollary 1 guarantees |l.f - pt.f| <= epsilon.
  2. c.j breaks ties strictly when l cannot advance: On local or send events, if l.j = l0.j, increment c.j := c.j + 1; otherwise reset c.j := 0. On receive, if l.j = l0.j = l.m, set c.j := max(c.j, c.m) + 1; if l.j = l0.j, set c.j := c.j + 1; if l.j = l.m, set c.j := c.m + 1; otherwise pt.j moved strictly ahead, so reset c.j := 0.

Replaying the Figure 4 loop under HLC (Figure 6) shows why drift stops cold: nodes 1, 2, and 3 stamp messages (10, 0), (10, 1), (10, 2) while l stays pinned at 10. As soon as any node’s pt advances past 10, l jumps to pt and c resets to 0. Even without assuming slow message rates, Corollary 3 bounds c.f <= N * (epsilon + 1) across N nodes, and if a message hop always spans at least d physical ticks, Corollary 4 shrinks that worst-case bound to epsilon / d + 1.

Consistent snapshots, 64-bit packing, and NTP resilience

Separating l from c turns HLC into a direct substitute for both Chandy-Lamport snapshots and TrueTime read timestamps, without special hardware or write pauses.

To take a consistent snapshot read at physical time t (Section 6.1, Figure 12), HLC uses virtual dummy events: between any two consecutive real events e and f on a node with l.e < l.f, conceptually fill in internal dummy states (t', c = 0) for every t' in [l.e + 1, l.f]. Now every node is guaranteed to have a state at (l = t, c = 0). Because (l.e, c.e) = (l.f, c.f) implies e || f (no causal path can share identical HLC pairs under Theorem 1), reading every node at (l = t, c = 0) yields a causally consistent global cut whose events all occurred within [t - epsilon, t]. Unlike Chandy-Lamport, no marker wave has to traverse the cluster at query time; unlike Spanner’s commit-wait, writes never stall waiting out [earliest, latest].

For backwards compatibility with existing storage formats, Section 6.2 packs (l, c) into a single 64-bit NTP timestamp. Standard NTP uses 32 bits for seconds (rolling over every 136 years) and 32 bits for fractional seconds (~233 picoseconds resolution). HLC rounds pt up via ceiling to the top 48 bits for l (preserving microsecond granularity) and devotes the bottom 16 bits to c (allowing c up to 65,535). Crucially, HLC operates as a superposition on NTP: it reads the OS clock without ever slewing or stepping it, avoiding Fan and Lynch’s impossibility trap where peer clock adjustments cause global drift away from real time.

How HLC stays resilient under NTP glitches, stragglers, and rushers
Backward NTP steps

Leap seconds or non-monotonic POSIX resets lower pt.j, so l.j holds steady and c.j increments until pt.j catches up.

Straggler vs. rusher nodes

In stress sims (1 event/ms), a 5x-lagging straggler hit c = 514 only locally; a 5x-ahead rusher peaked at c = 8 (<1% above 3).

Self-stabilizing guard Delta

Masking absorbs 99.9% of NTP kinks within Delta; messages exceeding Delta are ignored and corrupted local state resets to (pt, 0).

Resilience and simulation findings from Kulkarni et al. (2014), Sections 4 and 5.2.

Across live Amazon AWS runs on m1.xlarge nodes synced to 0.ubuntu.pool.ntp.org (75,000 to 425,000 wire-speed TCP messages), c and l - pt stayed far below theoretical bounds. On 4 nodes, c never exceeded 3 (83.90% at c = 0 under 5 ms NTP offset). On 8 nodes, tightening NTP sync from 9 ms to 3 ms lifted c = 0 from 65.56% to 91.18% and cut max l - pt from 107.9 ms to 7.4 ms (90th percentile falling from 41.4 ms to 0.1 ms). On 16 nodes at 6 ms offset, c peaked at 8 (75.43% at 0, max l - pt 46.8 ms, mean 0.3 ms). Across four WAN regions (Ireland, US East, US West, Tokyo) at 3 ms offset, transit time exceeded clock skew so incoming timestamps trailed local pt: 95% of events had c = 0, 5% had c = 1, and max l - pt was 0.02 ms.

Trace five timing scenarios through HLC

Burst traffic, lagging stragglers, and snapshot reads each hit a different branch of Figure 5’s rules. Switch through the tabs below to compare naive clocks, HLC behavior, and measured bounds.

Five distributed clock scenarios traced under HLC

Select a scenario (or use Left and Right arrow keys) to compare naive behavior, HLC's update rule, and empirical bounds.

Burst of local or send events within one clock tick

Local & send

A node generates multiple events faster than 48-bit physical time advances (or while NTP steps backward).

Why naive fix breaks
Raw physical time assigns identical or decreasing timestamps, violating causality; naive scalar l := max(l+1, pt) leaks permanent drift into l.
HLC's mechanism
l.j stays equal to l0.j = max(l0.j, pt.j), while c.j increments by 1; as soon as pt.j advances past l.j, c.j resets to 0.
Bit budget
48-bit ceiling rounding tracks microseconds; the remaining 16 bits allow up to 65,536 causal events per microsecond before overflow.
AWS cluster rate
In 4-node single-AZ wire-speed runs, c = 0 accounted for 83.66% to 83.90% of events and c never exceeded 3.

Source: Kulkarni et al. (2014), Sections 3 through 6.

If you skip clicking through the tabs, here is how HLC handles all five scenarios:

  • Same-tick bursts: l holds at max(l0, pt) while c counts causal steps (up to 65,536 per microsecond in 16 bits) until pt ticks forward and resets c = 0.
  • Fast messaging loops: holding l constant while incrementing c keeps |l - pt| <= epsilon, avoiding the unbounded runaway drift of single-scalar hybrids.
  • Stragglers: a lagging node borrows current l from peers and absorbs elevated c locally (up to 514 at 5 * epsilon lag) without infecting healthy nodes.
  • Rushers and corruptions: a tolerance bound Delta masks normal NTP jitter (c <= 8 in 5x rusher sims) while rejecting out-of-bounds timestamps and resetting corrupted state to (pt, 0).
  • Consistent snapshots: reading every shard at (l = t, c = 0) returns a causally consistent cut in [t - epsilon, t] with zero write-side commit-wait.

Caveats and production tradeoffs

Three caveats define what HLC solves and what distributed engineers still have to handle separately.

First, HLC provides one-way causality, not concurrency detection or strict serializability. As with Lamport clocks, (l.e, c.e) < (l.f, c.f) never implies e hb f, so conflict detection still needs vector clocks or Dynamo-style version vectors. Skipping commit-wait also means out-of-band external callers across lagging nodes can still violate real-time order unless databases add client-notification-wait or uncertainty read restarts.

Second, Delta tuning and 48+16-bit packing embed operational tradeoffs. Setting Delta too small turns routine 100 ms+ NTP glitches into dropped messages; setting it too wide lets a rusher pull cluster l ahead of wall time, widening [t - epsilon, t] snapshot staleness. Ceiling-rounding pt to 48 bits also assumes microsecond resolution suffices and 16-bit c (65,535) never overflows before pt advances.

Third, the 2014 benchmarks measured raw messaging, not transactional storage. The AWS runs tested 4 to 16 m1.xlarge nodes sending TCP messages alongside 1 event/ms simulations, leaving consensus queues and disk fsync tails to implementers. Even so, decoupling l from c gave distributed databases a durable, hardware-free 64-bit clock for consistent snapshots.