批处理 Google 驱动 API 请求是否有助于缓解 RateLimitExceeded 错误?
Does Batching Google Drive API Requests Help Mitigate RateLimitExceeded Errors?
我们的应用程序目前对 Google 驱动器 API 进行大量调用,以检索更改、权限、文件等。目前我们正在努力解决 403 rateLimitExceeded
错误.
根据文档here,有两种解决方案:
- 批处理请求。
- 使用指数退避重试请求。
我们希望实施批处理以帮助减少错误。但是,根据文档 here:
A set of n requests batched together counts toward your usage limit as n requests, not as one request. The batch request is taken apart into a set of requests before processing.
我想我的问题是,作为单个批次的一部分的一组 n 请求是否仍然算作 n 请求达到速率限制?这意味着如果一个批次包含的请求数量与触发 403 rateLimitExceeded
一样多,是否仍会返回该错误?
非常感谢任何帮助。
是的,确实,单个批次上的 n 个请求集计为 n 个请求,达到使用率限制。除了您在问题中提到的注释外,文档的其他部分(例如 this one)描述如下:
When the server receives the batched request, it applies the outer request's query parameters and headers (as appropriate) to each part, and then treats each part as if it were a separate HTTP request.
从前面的注释信息和这个可以清楚地看出,批处理请求中的每个请求都算作一个单独的请求,因此计入速率限制。
但是,如果您遇到错误 403 : rate limit exceed the problem is not the total amount of requests you are making but the rate at which you are making them (probably too many in too little time). That is why it recommends you to use exponential backoff (where if you send them too quick the script tries to send back the requests after a certain waiting time) or using batch requests(每批最多只能发送 100 个请求,这样可以减少服务器的开销)。
我建议您结合使用两者。如果您需要发出多个批处理请求(因为您发出的请求超过 100 个),我建议您对这些批处理请求使用指数退避。
我们的应用程序目前对 Google 驱动器 API 进行大量调用,以检索更改、权限、文件等。目前我们正在努力解决 403 rateLimitExceeded
错误.
根据文档here,有两种解决方案:
- 批处理请求。
- 使用指数退避重试请求。
我们希望实施批处理以帮助减少错误。但是,根据文档 here:
A set of n requests batched together counts toward your usage limit as n requests, not as one request. The batch request is taken apart into a set of requests before processing.
我想我的问题是,作为单个批次的一部分的一组 n 请求是否仍然算作 n 请求达到速率限制?这意味着如果一个批次包含的请求数量与触发 403 rateLimitExceeded
一样多,是否仍会返回该错误?
非常感谢任何帮助。
是的,确实,单个批次上的 n 个请求集计为 n 个请求,达到使用率限制。除了您在问题中提到的注释外,文档的其他部分(例如 this one)描述如下:
When the server receives the batched request, it applies the outer request's query parameters and headers (as appropriate) to each part, and then treats each part as if it were a separate HTTP request.
从前面的注释信息和这个可以清楚地看出,批处理请求中的每个请求都算作一个单独的请求,因此计入速率限制。
但是,如果您遇到错误 403 : rate limit exceed the problem is not the total amount of requests you are making but the rate at which you are making them (probably too many in too little time). That is why it recommends you to use exponential backoff (where if you send them too quick the script tries to send back the requests after a certain waiting time) or using batch requests(每批最多只能发送 100 个请求,这样可以减少服务器的开销)。
我建议您结合使用两者。如果您需要发出多个批处理请求(因为您发出的请求超过 100 个),我建议您对这些批处理请求使用指数退避。