2

I am getting

"code": 403, "message": "User Rate Limit Exceeded"

while using Google Drive API in my web app

Although the quota is 10,000 requests per 100 seconds and my average is less than 2:

usage graph

How can I resolve this error? How to implement exponential backoff as the documents say?

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
zamp
  • 41
  • 1
  • 1
  • 6

2 Answers2

2

There are sevrail types of quotas with Google apis.

Project based quotas which effect your project itself. These quotas can be extended. If for example you your project can make 10000 requests pre 100 seconds. you could request that this be extended.

enter image description here

Then there is the user based quotas. these quotas limit how much each user can send.

User Rate Limit Exceeded

Means that you are hitting a user rate quota. User rate quotas are flood protection they ensure that a single user of your application can not make to many requests at once.

These quotas can not be extended.

if you are getting a user rate limiting quota then you need to slow down your application and implement exponential backoff.

How you implement exponential backoff is up to you and the language you are using but it basically involves just retrying the same request again only adding wait times each time it fails

the graph

the graph in the google cloud console is an guestimate and it is not by any means accurate. If you are getting the error message you should go by that and not by what the graph says.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
2

After hours of searching and thinking, I found out that, 'User Rate Limit Exceeded' has a spam protection which allow max 10 requests per second.

Thus I found out a lazy trick to do so by delaying the calls using:

usleep(rand(1000000,2000000);

It simply delays the call by a random duration between 1 and two seconds.

zamp
  • 41
  • 1
  • 1
  • 6