Google App Engine - 推送任务处理率

Google App Engine - Push task processing rate

我想使用典型的推送队列在后台处理缓慢的操作。对于某些HTTP请求,应用会根据发送的参数创建新的任务。

我的应用程序处理来自我们客户安装的家庭自动化系统的 http 请求。安装系统的数量将每月增加 4000 个。每个系统将每 6 秒与服务器通信一次。但是,只有在事件发生并且嵌入到查询传递的参数中时才会创建任务。这种情况每天大约发生 600 次。在系统发送另一个任务之前处理系统发送的任务很重要,所以在 6 秒之前。任务使用 Objectify 读取数据并将数据存储在 Datastore 中,发送电子邮件以防万一或警报 and/or 推送到手机。

我的问题如下:

如何将处理速率、bucket-size 和 max-concurrent-requests 值固定到 queue.xml

我需要确保所有请求都得到处理并且所有任务都得到处理。但我不想为未使用的实例支付太多费用。

提前感谢您的回复。

对于您提到的用例,可能值得查看 Pub/Sub + CloudFunctions。

如果您的队列处理器在 AppEngine 标准中实现并使用自动缩放,那么它们将自动缩放以处理新负载。对于一些高吞吐量的情况,我对推送队列进行分片(例如,有 36 个队列 A-Z,0-9),然后根据对象 ID 进行哈希处理(如果需要,转换为基数 36),这样可以减少给定队列的压力。

所有答案都在queue.xmlreference中。在这个例子中:

<queue-entries>
  <queue>
    <name>fooqueue</name>
    <rate>1/s</rate>
    <retry-parameters>
      .....
    </retry-parameters>
  </queue>
  <queue>
    .....
  </queue>    
</queue-entries>

<queue-entries></queue-entries> 是您插入队列的根元素,在 <queue></queue> 中您可以定义:

  1. <rate>:

    The value is a number followed by a slash and a unit of time, where the unit is s for seconds, m for minutes, h for hours, or d for days. For example, the value 5/m says tasks will be processed at a rate of 5 times per minute....

  2. <bucket-size>

    Optional ..... [ ]...... If you don't specify bucket_size for a queue, the default value is 5. We recommend that you set this to a larger value because the default size might be too small for many use cases: the recommended size is the processing rate divided by 5 (rate/5).

  3. <max-concurrent-requests>

    Optional. Sets the maximum number of tasks that can be executed simultaneously from the specified queue. The value is an integer. By default, the limit is 1000 tasks per queue.

在您的特定情况下,假设您完全确定每天只有 600 个任务。这大约是每 144 秒执行一项任务。那是你的费率。在文档中它看起来像

<rate>600/d</rate>

看到其他两个值是可选的-