flitsmeister / maplibre-navigation-ios

Repo is moved to https://github.com/maplibre/maplibre-navigation-ios
Other
6 stars 5 forks source link

Fixed spammy when server doesn't respond #9

Closed Svantulden closed 4 years ago

Svantulden commented 4 years ago

Description

Last week, we encountered downtime on our navigation servers. It seemed that because of the downtime, a huge spike in iOS navigation requests occurred. We saw 3000% increase of requests for example, where we expect 20k requests we got 500k. We were puzzled why that would be.

Found out that the navigation SDK is the culprit.

How it works:

  1. The user drives on their route that was successfully calculated
  2. The SDK tries to find a faster route by doing a routing call to our servers every 2 mins (and some other requirements)
  3. After a while, the servers get downtime
  4. The SDK tries to search for a faster route again, but that call fails
  5. Because the call fails, the guard guard let route = route fails, and the lastLocationDate isn't set to nil
  6. That means that every location update thereafter will try to search for a faster route by doing a routing call
  7. ???
  8. Server-hosting: PROFIT! 💰
Spam

image

The fix

The fix is two-fold:

  1. Always setting the lastLocationDate to nil when the call is done, even if it fails. This means that the user has to wait 2mins (and other requirements) before it tries again in case of failure. That is fine in my opinion
  2. Only do one call at a time. When the server times out, it should wait for that before it retries.

This will reduce the spammy calls to our servers