Google AppEngine服务器实例时钟同步 [英] Google AppEngine server instance clock synchronization

查看:133
本文介绍了Google AppEngine服务器实例时钟同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在查询游标的 AppEngine文档中遇到以下段落 b
$ b


一个有趣的游标应用程序是监视
未见变化的实体。如果应用程序在每次实体更改时都设置带有当前
日期和时间的timestamp属性,则应用程序可以使用按照timestamp属性排序的查询
,并将数据存储区游标
检查实体何时移动到结果列表的末尾。如果更新
实体的时间戳,则带有游标的查询将返回
更新的实体。如果自上次执行
查询以来没有更新实体,则不会返回结果,并且游标不会移动


为了可靠地工作,必须对不同服务器实例中的时钟同步提供某种保证。否则,您可能会收到以下情形:
$ b $ ol

  • 服务器实例1(快速时钟)使用时间戳1000保存更新。

  • 客户端请求更新并找到此更新。

  • 服务器实例2(慢时钟)以时间戳950保存另一个更新。




  • 只要客户要求更新,并且没有找到此更新,因为时间戳不会增加。我明白,从来没有任何这样的时钟同步保证。这个改变了吗?



    更新:



    我刚才意识到即使时钟是同步的完美地,由于查询的最终一致性,这种方法可能会错过结果。如果稍后的更新在更早的更新之前结束提交,并将其更改为同时查询,而较早的更新不会,则它将隐藏更早的更新。或者我错过了什么?

    解决方案

    我在时钟和Google云端平台上找到的唯一文档是这里此处
    根据第一个链接文章,实例将使用NTP服务进行同步,并为您完成。


    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?

    解决方案

    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.

    这篇关于Google AppEngine服务器实例时钟同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆