1
votes

Our application currently makes lots of calls to the Google Drive API in order to retrieve changes, permissions, files, etc. Currently we're grappling with 403 rateLimitExceeded errors.

According to the documentation here, there are two solutions:

  1. Batch the requests.
  2. Use exponential backoff to retry the request.

We'd like to implement batching to help mitigate the errors. However, according to the documentation 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.

I guess my question is, does a set of n requests as part of a single batch still count as n requests towards the rate limit? Meaning if a batch contains as many requests as would trigger a 403 rateLimitExceeded, would that error still be returned?

Any assistance is greatly appreciated.

1

1 Answers

0
votes

Yes, indeed the set of n requests on a single batch counts as n requests towards the usage rate limit. Apart from the note you mentioned in your questions, other sections of the documentation (such as this one) describe the following:

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.

From the previous note information and this it is clear that each request in the batch request counts as a separate request counting therefore to the rate limit.

However, if you are getting the error 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 (where you can only send a maximum of 100 requests per batch and it reduces the amount of overhead to the server).

I would suggest you use a combination of both. If you are required to make several batch requests (because you are making >100 requests) I would recommend you use exponential backoff for these batch requests.