Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the TrueTime API in Google's Spanner?

I tried to read the document multiple times but failed to understand it. Can someone explain it in layman's terms?

like image 609
Sundar Avatar asked Oct 27 '16 00:10

Sundar


People also ask

What is TrueTime API?

TrueTime is an API available at Google that directly exposes clock uncertainty. Comparing to standard datetime libraries, instead of a particular timestamp, TrueTime's now() function returns an interval of time [earliest, latest]. It also provides two functions: after(t) returns true if t has definitely passed.

What is Google Spanner based on?

Google Cloud Spanner makes use of TrueTime, a Google Cloud clock synchronization service that uses a combination of atomic clocks and GPS technology.

Does Google Spanner break CAP Theorem?

The short answer is “no” technically, but “yes” in effect and its users can and do assume CA. The purist answer is “no” because partitions can happen and in fact have happened at Google, and during some partitions, Spanner chooses C and forfeits A. It is technically a CP system.

Does Google use atomic clock?

We use this technology to smoothly handle leap seconds with no disruptive events. We implemented Google Public NTP with our load balancers and our fleet of atomic clocks in data centers around the world.


1 Answers

TrueTime is an API available at Google that directly exposes clock uncertainty.

Comparing to standard datetime libraries, instead of a particular timestamp, TrueTime's now() function returns an interval of time [earliest, latest].

It also provides two functions:

  • after(t) returns true if t has definitely passed. E.g. t < now().earliest.
  • before(t) returns true if t has definitely not arrived, or t > now().latest.

What's impressive, is that the implementation of now() returns intervals with generally small uncertainty.

Spanner uses TrueTime API to assign a commit timestamps to transactions in the way that it satisfies external consistency: if a transaction T1 commits before another transaction T2 starts, then T1’s commit timestamp is smaller than T2’s.

More in the Spanner paper http://static.googleusercontent.com/media/research.google.com/en//archive/spanner-osdi2012.pdf

like image 129
Mairbek Khadikov Avatar answered Oct 21 '22 09:10

Mairbek Khadikov