Google Cloud Datastore,同时 read/write,可能发生冲突?

Google Cloud Datastore, simultaneous read/write, conflicts possible?

场景是,我启动了很多工作人员(Compute Engine VM),他们都查询状态为“打开”的相同数据存储类型。他们查询的限制可以说是 10k。然后工作人员通过 put_multi (python).

将状态更新为“运行”

实体同时访问会不会出现读写冲突?

Google Cloud Datastore 在使用上有一些限制,例如 Datastore 可以处理很多操作,但您需要遵循 Datastore 的 [=14= 中提到的规则 500/50/5 ].

这条规则说

We recommend a maximum of 500 operations per second to a new kind, then increasing traffic by 50% every 5 minutes. In theory, you can grow to 740K operations per second after 90 minutes using this ramp up schedule. Be sure that writes are distributed relatively evenly throughout the key range.

最佳实践文档也提到:

If you update an entity too rapidly, then your Datastore mode writes will have higher latency, timeouts, and other types of error. This is known as contention.

根据我的经验,contention 效果发生在每秒修改一次以上实体时,我的建议是每秒修改同一个实体一次(写操作)

遵循这些规则,同时读写不会有性能问题。

关于数据一致性,请记住同时启动的读取和写入操作会进入竞争状态,这可能会导致一些意外结果。

transactions 文档中所述,您可以使用这些来延迟第二个事务,避免由于事务锁定功能而导致的竞争条件

在此document中有一些使用事务处理数据一致性的代码示例。