Reputation: 7403
I'm adding a mapping function to one of the internal tools used by my company. Long story short, we have a list of about 50 addresses that need to be placed on a map. I'm using Google Maps so that it is an interactive map, and then the javascript API for geocoding and adding the markers.
According to Google's documentation, I am limitted to 10 requests per second. So, I've set my javascript to churn through an array of addresses, and put a delay in between each batch.
So my function is setup with two confif variables that I can set: addressesPerBatch and timeoutPerBatch - pretty obvious what each one should do. You would think that, judging from Google's documentation, I would be allowed
addressesPerBatch = 10;
timeoutPerBatch = 1000; //That's in milliseconds
I am most certainly not. I very quickly hit my rate limit when I send requests that quickly. The sweet spot that I've found is actually around"
addressesPerBatch = 2;
timeoutPerBatch = 2000;
So, is this a problem with my javascript, or a problem with Google's rate limiting?
I've created a jsfiddle so you can get a better idea of exactly what I'm doing: http://jsfiddle.net/Qt4gV/1/
Upvotes: 4
Views: 2878
Reputation: 1367
According to the answer to a similar question on the Google code page: "The Geocoding API request rate limit is not to be disclosed to help minimize service abuse." https://code.google.com/p/gmaps-api-issues/issues/detail?id=3099#c4
Like what @jwegner mentioned in the comments, one should check the returned status code and implement constant backoff for the case "OVER_QUERY_LIMIT".
Upvotes: 1
Reputation: 524
When I was doing large batches of geocoding, I did it serially with a timeout of about 0.25 seconds between each query. This didn't cause problems and was still fast enough. The DB updates too far longer than the request/response of the geocoding.
Also, if you have a Premier license make sure you follow the directions about adding a signature to the request or your requests will be treated like you were using the free license. I learned this the hard way when I maxed out my daily limit with few test run on my development server!
Upvotes: 0