【问题标题】:How to compute the percentage of failed tasks in Google AppEngine?如何计算 Google AppEngine 中失败任务的百分比?
【发布时间】:2015-09-23 15:52:27
【问题描述】:

我正在使用来自 GAE (python) 的 push task queue。有时 X 分钟后,Y% 的任务失败。 对于这种情况,我想清除任务队列(不需要执行它们,最终很多会失败)。

我可以配置一个任务在重试超过 2 次时停止执行,但如果我有 100 个任务失败(300 次运行 = 100 + 200 次重试),我该如何停止剩余任务的执行?

queue.yaml:

queue:
- name: my-queue
  mode: push
  rate: 1/s
  bucket_size: 10
  max_concurrent_requests: 10
  retry_parameters:
    task_retry_limit: 2

【问题讨论】:

    标签: google-app-engine task-queue


    【解决方案1】:

    我会在内存缓存中存储一​​些值,例如 number of tasks in queuetimestamps of tasks that failed

    每个任务都需要执行这些任务:

    • 开始时,计算滚动百分比(在最后 X 分钟内)并在百分比过高时退出,或者增加 number of tasks 计数器并继续。
    • 失败时, 递减number of tasks 计数器并向 failed tasks 列表。
    • 成功后,减少number of tasks 计数器。

    要计算滚动百分比,请获取 failed tasks 的整个列表并过滤掉那些太旧的时间戳(超过 X 分钟前)。将新列表放回内存缓存。然后,取number of tasks 计数器并计算100.0 * (number of failed tasks) / (number of tasks) 以获得您的百分比。如果超过 Y% 阈值,请立即退出您的任务。

    【讨论】:

      猜你喜欢
      • 2023-03-21
      • 2019-11-06
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      • 2017-03-28
      • 2020-10-20
      • 1970-01-01
      相关资源
      最近更新 更多