Google AppEngine server instance clock synchronization

亡梦爱人 提交于 2019-12-23 09:47:11

问题


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?


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!