Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

mapkit - 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??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...