Google云端存储中的速率限制

时间:2015-08-21 21:36:46

标签: google-cloud-storage

在每分钟的情况下,我的代码总共会将20到40个文件(从多台计算机,大约5个并行文件,直到它们全部上传)上传到Google云端存储。我经常得到429 - Too Many Errors,如下所示:

java.io.IOException: Error inserting: bucket: mybucket, object: work/foo/hour/out/2015/08/21/1440191400003-e7ba2b0c-b71b-460a-9095-74f37661ae83/2015-08-21T20-00-00Z/
        at com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.wrapException(GoogleCloudStorageImpl.java:1583)
        at com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl$3.run(GoogleCloudStorageImpl.java:474)
        ... 3 more
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 429 Too Many Requests
{
  "code" : 429,
  "errors" : [ {
    "domain" : "usageLimits",
    "message" : "The total number of changes to the object mybucket/work/foo/hour/out/2015/08/21/1440191400003-e7ba2b0c-b71b-460a-9095-74f37661ae83/2015-08-21T20-00-00Z/ exceeds the rate limit. Please reduce the rate of create, update, and delete requests.",
    "reason" : "rateLimitExceeded"
  } ],
  "message" : "The total number of changes to the object mybucket/work/foo/hour/out/2015/08/21/1440191400003-e7ba2b0c-b71b-460a-9095-74f37661ae83/2015-08-21T20-00-00Z/ exceeds the rate limit. Please reduce the rate of create, update, and delete requests."
}
        at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
        at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
        at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:432)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
        at com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl$3.run(GoogleCloudStorageImpl.java:471)
        ... 3 more

我有一些重试逻辑,这有点帮助,但即使经过一些指数退避和最多3次重试,我仍然经常得到错误。

奇怪的是,当我访问Google Developers Console时 - > API& auth - > API - >云存储API - >配额,我看到Per-user limit 102,406.11 requests/second/user。当我查看“使用情况”选项卡时,它没有显示任何用法。

我错过了什么?将文件上传到GCS时,如何停止限速?为什么我的配额如此之高,我的使用率报告为0?

2 个答案:

答案 0 :(得分:2)

当您尝试过于频繁地更新同一对象时,会发生该错误。来自https://cloud.google.com/storage/docs/concepts-techniques#object-updates

"您可以多快地创建或更新存储桶中的不同对象。但是,单个特定对象只能更新或覆盖每秒一次。"

答案 1 :(得分:1)

根据你对同一时刻采取行动的多台机器的描述来判断,我怀疑你的所有机器都试图在同一时刻写出完全相同的对象名称。 GCS限制每秒针对任何一个对象的写入次数(每秒1次)。

因为看起来您的对象名称以斜线结尾,就像它们本来是一个目录一样(" work / foo / hour / out / 2015/08/21 / 1440191400003-e7ba2b0c-b71b -460a-9095-74f37661ae83 / 2015-08-21T20-00-00Z /"),您是否可能想要用一些独特的价值或机器名称或其他东西来结束它们,但是还是留下了这一点?