没有祖先的新实体导致 "Too much contention" 错误

New entity without ancestors caused "Too much contention" error

今天,由于 "too much contention on these datastore entities",我在 App Engine 上的实时 Python 应用程序在十分钟内收到了大约 100 个请求,在向数据存储区写入新实体时抛出了异常。我的应用程序只为每个请求写入一个实体。在此期间并非所有请求都失败;大多数都成功了。

几个星期以来,该应用程序已经处理了大约。一天30k请求没问题,没见过QPS超过20的。其实有请求间隔大于一秒写失败的例子。 我正在使用 db 库,这是模型定义:

class SiteImpression(db.Model):
    remoteIPAddr = db.StringProperty(required=True)
    aPersonID = db.StringProperty(required=True)
    requestURI = db.TextProperty(required=True)
    serverEnvironment = db.StringProperty(required=True)
    requestDateTime = db.DateTimeProperty(required=True)
    userAgent = db.TextProperty(required=True)

以及写入数据存储的代码:

dtDateTime = datetime.now()
e = myd.SiteImpression(remoteIPAddr=strRemoteAddr,
                       aPersonID=straID,
                       requestURI=strRequestURI,
                       serverEnvironment=strEnvironment,
                       requestDateTime=dtDateTime,
                       userAgent=strUserAgent)
e.put()

来自阅读 this SO question, I gather this has to do with my indexed datetime property causing hot tablets (which I have read about here) 的答案。我有这个日期时间 属性 的默认索引和两个自定义索引:

- kind: SiteImpression
  properties:
  - name: aPersonID
  - name: serverEnvironment
  - name: requestDateTime
    direction: asc

- kind: SiteImpression
  properties:
  - name: serverEnvironment
  - name: requestDateTime
    direction: asc

我的问题:我是不是做错了什么导致了这些争用问题,或者可能只是数据存储的临时问题?

谢谢。

问完这个问题后,我收到了一封来自 google-appengine-downtime-notify 组的电子邮件:https://groups.google.com/forum/#!topic/google-appengine-downtime-notify/cAr5V_EWs-g

在我收到错误的同一天写入索引时出现临时问题。