问题
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:
- Server instance 1 (fast clock) saves an update with time-stamp 1000.
- Client asks for updates and finds this one update.
- Server instance 2 (slow clock) saves another update with time-stamp 950.
- 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?
回答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.
来源:https://stackoverflow.com/questions/18264338/google-appengine-server-instance-clock-synchronization