How to Get Mobile Data Sync Right with Mobile Backend as a Service (MBaaS)

Steve Jurczak

#Mobile

Twenty years ago, Watts Humphrey, known today as the "Father of Software Quality," declared that every business is a software business. While his insight now seems obvious, digital technology has evolved to where we can add to it: Every business is also a mobile business. According to Gartner, 75% of enterprise data will be generated and processed away from the central data center by 2025. And according to data.ai, 84% of enterprises attribute growth in productivity to mobile apps.

Today, mobile tech transforms every aspect of business. It enables the workforce through point-of-sale, inventory, service, and sales. It streamlines critical business processes like self-checkout and customer communications. And it powers essential work devices from telemetry to IoT to manufacturing.

The data businesses capture on mobile and edge devices can be used to improve operational efficiency, drive process improvements, and deliver richer, real-time app experiences. But all of this requires a solution for synchronizing mobile data with backend systems, where it can be combined with other historical data, analyzed, or fed into predictive intelligence algorithms to surface new insights and trigger other value-add activities. But syncing mobile data with backend systems can be hard for a number of reasons.

Mobile devices are constantly going in and out of coverage. When connections break and then resume, conflicts emerge between edits that were made on devices while offline and other data that's being processed on the backend. So conflict resolution becomes a crucial part of ensuring changes on the mobile device are captured on the backend in a way that ensures data integrity.

Sync and swim

Apps that are not designed with backend sync in mind can take a long time to load, are prone to crashing, and show stale information. When apps don’t deliver positive experiences, people stop trusting them — and stop using them.

On the other hand, an app with robust sync between a device’s local data store and the back end lets workers see live data across users and devices, allowing for real-time collaboration and decision-making. According to Deloitte, 70% of workers don’t sit at a desk every day, so the ability to sync data will increasingly drive business outcomes.

Indian startup, FloBiz, uses MongoDB Atlas Device Sync to handle the difficult job of keeping the mobile, desktop, and web apps in sync. This means even if multiple users were using the same account, going offline and online, there would be no issues, duplications or lost data.

Why data sync is difficult

A lot of organizations choose to build their own sync solutions. DIY solutions can go one of two ways: overly complex or oversimplified, resulting in sync that happens only a few times a day or in only one direction. It can be complicated and time-consuming for developers to write their own conflict-resolution code because building data sync the right way takes potentially thousands of lines of code. Developers frequently underestimate the challenge because it seems straightforward on the surface. They assume sync consists simply of the application making a request from the server, receiving some data, and using that data to update the app’s UI on the device. But when building for mobile devices this is a massive oversimplification.

Representation for how people perceive building sync versus what it is actually like; visualized by an iceberg. Above the surface is what people thing building sync is like, which is as follows; Step 1, applications request. Step 2, received data. Step 3, Update UI. Below the surface of the iceberg is what building sync is actually like, which is a complicated weave of questions and steps intertwined together. There are plenty of chances for the app to fail, which would result in a retry of the system.
Building data sync can be more complicated than people assume.

When developers attempt to build their own sync tool, they typically use RESTful APIs to connect the mobile app with the backend and exchange data between them. Mobile apps are often built more like web apps in the beginning. But once the need to handle offline scenarios arises, and because some functionality requires local persistence, then it becomes necessary to add a mobile database. Syncing with that mobile database then becomes a challenge. The exchange of data between the device and the back end gets complicated. It requires the developer to anticipate numerous offline use cases and write complex conflict-resolution code. It can be done, but it’s a time-consuming process that’s not guaranteed to solve all use cases. When data is requested, applications need to understand whether a network is available, and if not, whether the appropriate data is stored locally, leading to complex query, retry, and error handling logic.

The worst part about all this complexity is that it’s non-differentiating, meaning it doesn’t set the business apart from the competition. Users expect the functionality powered by data sync and won’t tolerate anything less.

An integrated, out-of-the-box solution

MongoDB's Atlas Device Sync combined with Realm is a mobile backend as a service (MBaaS) solution that enables developers to build offline-first applications that automatically refresh when a connection is reestablished. Local and edge data persistence is managed by Realm, a development platform designed for modern, data-driven applications. Developers use Realm to build mobile, web, desktop, and IoT apps. Realm is a fast and scalable alternative to SQLite and Core Data for client-side persistence. The bidirectional data synchronization service between Realm and MongoDB Atlas allows businesses to do more with their data at the edge by tapping into some of MongoDB’s more powerful data processing capabilities in the cloud. Complex synchronization problems such as conflict resolution are handled automatically by MongoDB’s built-in sync.

To learn more about the challenges of building real-time mobile apps that scale, with sample use cases about how thousands of businesses are handling it today, download our white paper, Building Real-time Mobile Apps that Scale.