19

Using the google url shortener api, it was working fine till I started testing at load. Quickly started getting back 403 Rate Limit Exceeded errors from Google, even though I signed up to use the API and it comes with 1,000,000 hits a day. I can see the requests coming in on the google reporting tool, and they are just sending back 403's for everything. 403's started coming back at around 345/350 hits to the API, have been continuing for hours.

Thoughts?

MyBrokenGnome
  • 646
  • 2
  • 5
  • 16

4 Answers4

8

The API limits requests to 1 request / per second / per user.

A user is defined as a unique IP address.

So if you were doing your load testing from a single IP this would have cause your rate limit issue.

https://developers.google.com/analytics/devguides/reporting/mcf/v3/limits-quotas#general_api

Chase
  • 9,289
  • 5
  • 51
  • 77
  • 1
    Is this documented somewhere? I couldn't seem to find any information beyond the 1,000,000 per/day limit. I'm having this issue when people hit my API with a lot of requests I seem to be exceeding the `1 request / per sec / per user` limit – timbrown Nov 11 '14 at 21:34
  • 2
    https://developers.google.com/analytics/devguides/reporting/mcf/v3/limits-quotas#general_api – Chase Nov 11 '14 at 22:00
  • Thanks for this. It looks like you can change the rate quote up to ~PER USER LIMIT 1 requests/second/user~ but when trying to save it throws a 500 error. Am I missing something to be able to increase this to 10/sec/user? – timbrown Dec 04 '14 at 06:25
  • Sorry not sure what to tell you, I am able to change mine without any error. – Chase Dec 08 '14 at 21:03
  • 4
    That documentation is for Analytics, does it apply to Url Shortener ? I do not think so... – David Clavijo May 07 '15 at 17:25
  • 2
    Can we increase this limit some how ! I even tried upgrading my account to paid account ; still I cannot change this limit. – Deepak Singhal Jan 10 '17 at 17:59
  • 2
    `1 request / per second / per user` is honestly a joke. I didn't even assume it's so low when I integrated Google shortener into my app. – Csaba Toth Mar 06 '17 at 22:06
2

I don't think "1 request / per second / per user." as written in doc is 100% correct in my case, or the google url shortener case. (FYI: I am using "Public API access", not "OAuth")

I have almost the same problem but, for me, it is more likely to be "I get this error for some URLs for some period of times." What does it mean? Please continue reading.

These are what I found:

  • I can use 10 threads to use google url shortener at the same time, but not always ...
  • when processing, even one url is fail on one thread, the other threads still can get the other urls.
  • when a url is fail, and later I tried the same url again (even there are no other processes running, it still does not work for some PERIOD OF TIME. Even, I tried to add more string like "&test=1", it does not help. But if I changed to another url, it works.

So, I guess that google's server may have cache of each url. If a url is fail, it must wait for a while to let the cache released.

So, I have to write some creepy code like this to solve my problem:

  • when there is a fail, that particular thread will sleep for 1 minute (yes 1 minute)
  • and keep trying for 10 times (so totally, it can be 10 minutes for a fail url)

However, this creepy code is fine for my case because I am using ExecutorService with fixed-thread-pool size of 10. So, if there is a fail, the others still can get the shorten urls. It solves the problem...at least for me.

Surasin Tancharoen
  • 5,520
  • 4
  • 32
  • 40
-5

You need to go to the google shortener extension, and in option select 'Grant Access'

Wolfsbro
  • 1
  • 1
  • 4
    This question is not asking about the google chrome extension, but is related to consuming the service via the API and running into rate limits. – timbrown Nov 11 '14 at 21:42
-8

Right-click on the Extension icon, go to Options and click Grant Access on the bottom.