When building an app that connects to a web service it’s often best to put the processing load on your server, as opposed to the app.
For example, say your web service returned a list of addresses to your app. To show these on a map, the app could go and reverse geocode each one to get its latitude longitude, and then show a pin on the map.
A better solution would be to have the server do this work, and include the latitude longitude alongside the address.
This provides many advantages (some generic, some specific to this example):
- A mobile phone’s network is unreliable, people move in and out of bad coverage areas such as tunnels frequently. A server has a very reliable connection.
- A mobile phone has a battery, any unnecessary work is going to impact your user’s battery life. The example used above may have a negligible impact on the battery (it will have an impact, even if extremely low), however other examples may yield noticeable battery drain (see the very end of this post).
- A mobile phone’s processor is a lot slower than a server. If processing large quantities of information, it’s going to happen faster on a server.
- In the example above, if you found the geocoding service used was inaccurate, changing it would require an update to the app. If the server was doing this work then it’s easy to update without needing to change the app.
Of course there are other trade offs to consider. The main advantage of processing information in an app is that you do not need to be online to do so. This obviously doesn’t apply to my example above, where geocoding requires a network connection anyway.
Another good example of this in action is Apple’s push notification system. To send a push notification it must be sent through Apple’s push notification server, instead of directly to the app. If it was going directly to the app, then each app on your phone that uses push notifications would need to maintain an active connection to whatever sever sends out the notifications. Because all notifications go through Apple, instead the device can maintain just a single connection with Apple, which acts as the middleman for all notification activity. Because of this, the notification system has very little impact on battery, even though it puts an extreme load on Apple’s servers (they send millions of notifications every second).