Sync Framework & Local Database

sushilronghe
4 min readAug 11, 2016

--

Why Sync is required in first place?

When it comes to enterprise mobility, offline support is must to have kind of feature. Offline support in broader term means ability for the application to respond to user actions such as viewing, adding, or modifying data even in absence of the network connectivity. Mobile devices often present a scenario where internet connection is not available or unstable to make a underline request. Enterprise mobile apps must be equipped to handle such scenarios to provide a seamless user experience and un-interrupted business process.

All of the transactions/data committed during the offline mode on the mobile app must be sent to the server backend when internet connection is available to update the centralized database. This process of synchronizing the local data to the server data is referred to as a sync.

Offline feature impacts the front end as well as back-end server architecture. It can also have an invariable impact on the operational cost, which makes it one of the key factor to consider while making a design decision for mobile app and back-end.

What is sync framework?

Since the process of sync is so well defined in mobility architecture there are sync frameworks available which can quickly enable the developer to build sync functionality in their app. Sync framework generally comes in two pieces.

First part is a plug-gable piece of the software for front end. Referred as Platform[Android/IOS] SDK

It provides a data storage which could be local cache or database to store the data committed by user during the offline state. This data storage is referred as offline/Local storage. Offline storage enable the user to access the data when mobile network is not available. Other functionality it provides is synching the offline stored data to the server back-end.

Second part is Server piece provides a REST API to accept the data transactions and central storage.

Some of the notable sync frameworks are

  • Google Firebase
  • Couch Base
  • Microsoft Azure Mobile SDK & Storage
  • Kinvey
  • Parse
  • Appcelerator
  • MangoDB (partial only provides a server side data storage piece)

Which sync framework is right for your application

One can choose a ready made MBaas platform or build one from scratch. If you have an existing backend with some sort of web application running on top of it then you have no choice but build your own sync framework or extend the functionality of any existing MBaas by plugging your own sync code.

Few years back most of the enterprise application backend were built using Java platform + SQL. Now business wants to extends their operations to mobility. So it is very likely that you will be presented with a java enterprise based backend and asked to use the same for the mobile app with offline support. In this particular case, your challenge train will have to make several tough decisions stops before arriving to the destination.

Considerations for local storage

In most cases mobile application stores data in non-relational NOSQL format. JSON being the most popular choice for storing objects in NOSQL database, pretty much every NOSQL database framework provides adapter for the JSON object.

If your application is cordova based cross platform app then you have plenty of choices to select the NOSQL database. For native mobile application there are very few options or almost no options for NOSQL database and one has to depend on the SQL-lite port to store data in SQL database.

This is probably one of those few advantages cross platform app has over Native.

Database Options for Mobile Apps

So how does popular frameworks mentioned above handle the Native Scenario. Most of the sync framework use SQLite as the database to store json document. One might argue that; It is not the right choice since SQL support typed data and fixed schema how would one take advantage of the indexing and SQL query if we are dumping json document in SQL table?

MBaas Platform and Database Choice

Well like it or not but that;s currently the only option majorly accepted for Native App.

Once we decide the datababse and API for storing and retrieving the data, then comes the major task of synching this information to server. This is where well tested MBaas frameworks shines over DIY approach. Syncing the delta to the server is very critical task and if anything goes wrong then it would result in “Loss of Data”, “Data Over-writing” etc.. If the backend is also tied to a web application and you have complex user provisioning in place then one has to define the policy for overwriting the data. Over all defining the backend for synching is complex task and requires lot of time and effort if you are trying to build it from scratch.

Conclusion

There are plenty of options available when it comes to MBaas platform. Cross platform application runs in webview which by origin provides several ways to store untyped data, one has many options to select the database store when developing cross platform apps. Native app however does not have much choice but to use the SQL DB for local caching and data storage. Synching the delta is technically challenging task and it requires a several iterations cycles to build a perfect system for synching backends however ready made MBaas can come in handy to save time and effort.

--

--