Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS app getting throttled from local searches

I am implementing autocomplete (one search per new character added) in an app that searches for addresses, and I keep getting MKErrorDomain error 3, which is MKErrorLoadingThrottled. This error, according to Apple dev, occurs when

The data was not loaded because data throttling is in effect. This error can occur if an app makes frequent requests for data over a short period of time.

I know exactly how many requests are being made, one for each new charachter in the search query (just like you would expect autocomplete to work). Sure, I am a fast typer, but being able to hit the limit after just 10 or 15 requests seems absurd. Looking at the following two source references, I do not understand why I keep getting throttled.

According to Apple dev:

There are no request limits per app or developer ID, so well-written apps that operate correctly should experience no problems. However, throttling may occur in a poorly written app that creates an extremely large number of requests.

and as James Howard said at a WWDC:

And the other thing I want to talk about is the Usage Limits on this API. So, I'm happy to announce that there's no application or developer identifier wide usage limits. So, if you have a app that has a lot of users and you want to do a lot of requests, that's fine.

It'll work.

And the throttling that we do have is really just a first line of defense against buggy apps. So, if you put directions requests or local search requests in an infinite loop, you've got a bug, eventually you're going to get throttled.

But if you do something reasonable, you say oh, I'm going to just do directions in response to user input and you know you can do a few of those because we showed them that example.

Like we did two directions request in response to one user input, that's fine. But, you know if you're doing 10,000 every time the user taps on the screen, then you're going to get throttled. But, just keep it reasonable and you'll be fine.

Any ideas to why this is happening??

like image 774
Daniel Larsson Avatar asked May 06 '14 21:05

Daniel Larsson


1 Answers

Autocompletion requires a special APIs. MapKit doesn't offer such an interface. Just firing off dozens of requests to the normal search API causes a tremendous load.

You basically have two options:

  1. Go with Google Places. They have a dedicated Places Autocompletion API. There is even a complete library for iOS on GitHub.

  2. Reduce the number of requests, e.g. by only sending a request if the user has paused typing for 300ms and only if no earlier request is outstanding. But that's still no guarantee that Apple won't throttle your requests.

like image 104
Torino Avatar answered Oct 12 '22 10:10

Torino