Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google AppEngine server instance clock synchronization

I just came across the following paragraph in the AppEngine documentation for Query Cursors:

An interesting application of cursors is to monitor entities for unseen changes. If the app sets a timestamp property with the current date and time every time an entity changes, the app can use a query sorted by the timestamp property, ascending, with a Datastore cursor to check when entities are moved to the end of the result list. If an entity's timestamp is updated, the query with the cursor returns the updated entity. If no entities were updated since the last time the query was performed, no results are returned, and the cursor does not move.

For this to work reliably, there would have to be some sort of guarantees about the clock synchronization across different server instances. Otherwise you could get the following scenario:

  1. Server instance 1 (fast clock) saves an update with time-stamp 1000.
  2. Client asks for updates and finds this one update.
  3. Server instance 2 (slow clock) saves another update with time-stamp 950.
  4. Client asks for updates and does NOT find this update as time-stamp didn't increase.

As far as I understood, there never were any such clock synchronization guarantees. Did this change???

Update:

I just realized that even if the clocks were sync'ed perfectly, this approach might miss results due to the eventual consistency of queries. If a later update ends up getting committed before an earlier update and makes it into a simultaneous query while the earlier one doesn't, it will hide the earlier update. Or am I missing something?

like image 651
Markus A. Avatar asked Aug 16 '13 01:08

Markus A.


1 Answers

The only docs that i found on clock and Google Cloud Platform, are here and here. According to the first link post, instances are synced using NTP service, and it's done for you.

like image 72
Bogdan.Nourescu Avatar answered Oct 13 '22 22:10

Bogdan.Nourescu