Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Calendar api - rate limit exceeded (even though it's not)

I have an App Engine app that works with various Google APIs. I started a sync task that syncs like 3000 events to various users calendars. It worked for a while but now I am getting the following error:

PHP Fatal error:  Uncaught exception 'Google_Service_Exception' with message '{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "rateLimitExceeded",
    "message": "Rate Limit Exceeded"
   }
  ],
  "code": 403,
  "message": "Rate Limit Exceeded"
 }
}

If I look into the Api Dashboard, the limit is really high:

Queries per day 1,000,000
Queries per 100 seconds per user 50,000,000.

How can I get over this error? I want this task to finish so users see the events in their calendar.

like image 684
Filip Avatar asked Jan 08 '18 08:01

Filip


2 Answers

As stated in the documentaion user rate limit is flood protection. An application can only make X number of requests per second.

403: Rate Limit Exceeded The per-user limit from the Developer Console has been reached.

    {
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "rateLimitExceeded",
    "message": "Rate Limit Exceeded"
   }
  ],
  "code": 403,
  "message": "Rate Limit Exceeded"
 }
}

Suggested actions:

Use exponential backoff.

You can try adding quota user this helps sometimes.

quotaUser An arbitrary string that uniquely identifies a user.
Lets you enforce per-user quotas from a server-side application even in cases when the user's IP address is unknown. This can occur, for example, with applications that run cron jobs on App Engine on a user's behalf. You can choose any arbitrary string that uniquely identifies a user, but it is limited to 40 characters.

If you are getting a quota error then it has been exceeded even though you dont think it has. Application level quotas can not be increased. The only thing you can do is slow down.

like image 85
DaImTo Avatar answered Nov 15 '22 10:11

DaImTo


I could not find an answer to this question either. The default is 500 requests per 100 seconds, and even if I increased it, after some time, I can only make 5 requests/second which matches with a limit of 500.

That means the old default is always being used.

like image 26
Veaceslav Avatar answered Nov 15 '22 09:11

Veaceslav