Google AppEngine server instance clock synchronization
Asked Answered
E

1

6

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?

Expressman answered 16/8, 2013 at 1:16 Comment(2)
I have never found an official statement about clock sync. on IRC with google folks they said stuff was synced and I believe it however this post from a google dude is probably a good indication of the state of play groups.google.com/forum/#!searchin/google-appengine/… . Personally in the early days of appengine I have seen clock skews between instances > 30secs. Last time I checked I couldn't find any significant skew ;-)Tirol
This is really just a bad example on the docs because there are a lot of edge cases to worry about (like you mentioned). Even with perfect clock sync and strong consistency, setting a timestamp field to now() and when something gets sent to the Datastore could be delayed.Ardoin
T
1

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.

Tourcoing answered 25/5, 2015 at 11:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.