Google DataStore - 批量保存争用太多

Google DataStore - Too much contention with batch save

我有这个简单的结构

ParentEntity 
   => ChildEntity

我像这样将 20K 个子实体放在一个保存中

ofy().save().entities(childEntities).now() 

但它因争用过多而失败,但它适用于 10K-14K 实体。 我找不到它达到了哪个限制,请参阅 Limits page

您提到的限制页面指出 -

Maximum write rate to an entity group - 1 per second

Note you can batch writes together for an entity group. This allows you to write multiple entities to an entity group within this limit.

同一页面还指出每个 commit/write 的最大实体数为 500。如果所有 20,000 个实体都是单亲(实体组)的子代,则您的写入速度会受到上述限制。尝试将写入拆分为每批少于或等于 500 个实体,并在每批之间添加轻微的延迟(1 秒)。