开发者

AppEngine: How do I get the sequence of datastore write events?

I need a sequencer for the entire a开发者_Python百科pplication's data.

Using a counter entity is a bad idea (5 writes per second limit), and Sharding counters are not an option.

GMT time stamp seems unsafe due to clock variances with servers, plus a possible server time being set/reset.

Any idea? How do I get a entity property which I can query for all entities changed since a given value?

TIA


Distributed datastores such as the app engine datastore don't have a global sequence - there's literally no way to determine if entity A was written to server A' before entity B was written to server B' if those events occur sufficiently close together, unless you have a single machine mediating all transactions and serializing them, which places a hard upper bound on how scalable your system can be.

For your actual practical problem, the easiest solution would be to assign a modification timestamp to each record, and each time you need to sync, look for records newer than (that timestamp) - (epsilon), where epsilon is a short time interval that is longer than the expected difference in time synchronization between servers (something like 10 seconds should be ample). Your client can then discard any duplicate records it receives.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜