PTP based clock synchronization


I am new to CockroachDB.

I have started to read the architecture document and found myself deep diving into the clock synchronization challenge. According to the documentation CockroachDB make use of Hybrid logical and physical clock while Google’s Spanner solution uses atomic and GPS based clocks to bound the clocks drift to 7ms.

I didn’t see any solution that tries to leverage PTP (1588) which provide very accurate clock synchronization.

Any reason why ? What do I miss here ?


CockroachDB does not attempt to do perform clock synchronization, this is a task best left to dedicated tools like NTP (or PTP, or TrueTime, in Spanner’s case).

CockroachDB merely does its best to cope with poorly synchronized clocks, and it does so using hybrid logical clocks.

We currently recommend that CockroachDB operators use NTP to synchronize node clocks, but if you’d like to use PTP instead, that’s up to you.

Thanks Tamir.

To the best of my knowledge NTP maintain time to within tens to hundreds of milliseconds.
I am wondering if this may lead to performance penalty since a larger uncertainty window means higher potential for transactions to abort.
Should I expect a better performance when using more accurate clock synchronization methods (PTP, TrueTime) ?

You can reduce the max clock offset (via COCKROACH_MAX_OFFSET) from the default of 250ms if your synchronization method can guarantee a smaller value. You should see improved performance with a reduced offset (fewer transaction restarts due to clock uncertainty), depending on workload…