google-apigoogle-drive-apiexponential-backoff

How to Resolve a 403 error: User rate limit exceeded in Google Drive API?


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?


Solution

  • 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.