Google Drive API文件观看率限制 [英] Google Drive API file watch rate limits

查看:226
本文介绍了Google Drive API文件观看率限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Drive API,并在收到手表通知(频道)时收到以下错误:

 错误调用POST https://www.googleapis.com/drive/v2/files/xxxxxxxxxxxxxx/watch:(403)创建文件订阅超出限制

是否存在一个特定的记录费率限制:

a)每秒要求新频道(观看通知)



b)每天并发频道(观看通知)

我已阅读此问题
每秒只有1次插入后的403次速率限制,但它不会我真的很感激,如果你能指出我正确的方向。

解决方案

403率是你的敌人 - 避免它们。 Google使用令牌/存储桶机制进行速率限制。这意味着您可以将大量的API调用突破至25-39左右,而不会出现任何问题。之后,令牌每秒补充大约1次。这通常意味着在第一个30秒之后,除非你自愿将它们每1.5秒降到一个以下,否则大部分后续交易都会失败。这比指数回退更有效,这通常会导致第一次回退失败,第二次回退成功。结果是3次Drive API调用,成功呼叫3秒(加上网络)。如果您在第一个403之后进行节流,则每个订阅都将是一个Drive API调用,并在1.5秒后成功。如果你正在做很多订阅,这些额外的1.5s很快就会加起来。



<403> 403的一个问题是有时事务实际上已经成功了。我怀疑这是否是手表订阅的问题,但可以用于插入和更新。


I am working with the Google Drive API, and receiving the following error when putting through watch notifications (channels)

Error calling POST https://www.googleapis.com/drive/v2/files/xxxxxxxxxxxxxx/watch: (403) Rate limit exceeded for creating file subscriptions

Is there a specific, documented rate limited for:

a) Requesting new channels (watch notifications) per sec

b) Concurrent channels (watch notifications) per day

I have read through this question 403 rate limit after only 1 insert per second , but it doesn't really provide an answer

I would be grateful if you could point me in the right direction.

解决方案

403 rate limits are your enemy - avoid them. Google does rate limiting using a token/bucket mechanism. This means you can burst a number of API calls up to around 25-39 with no problems. After that the tokens are replenished at approx 1 per second. This generally means that after the first 30, most of your subsequent transactions will fail unless you voluntarily throttle them below one every 1.5s. This is far more effective than exponential backoff, which will often result in the first backoff also failing, with success occurring on the second. The result is 3 Drive API calls with the successful call taking 3 seconds (plus network). If you throttle after the first 403, each subscription will be a single Drive API call and will succeed after 1.5s. If you are doing many subscriptions, those additional 1.5s soon add up.

One of the issues with 403's is that sometimes the transaction has actually succeeded. I doubt if it's an issue for watch subscriptions, but can be for inserts and some updates.

这篇关于Google Drive API文件观看率限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆