What does offline-first mean?

The term “offline-first” describes a mobile app that is built to perform most, or all, of its core functionality without access to the Internet. The concept is simple enough, but all too often this is not how a mobile app is developed. Instead, it is built to access data from distant cloud data centers, making it dependent on the internet. This means that when the network connection slows or becomes unavailable, so does the app, frustrating users and eroding adoption. By building an app with an “offline-first” approach, you essentially eliminate Internet dependencies, making the app faster and more reliable.

A key to the offline-first concept is understanding that it doesn’t apply only to use cases in remote locations, instead, it should be considered the standard approach for any mobile app development effort.

Let’s explore that notion further…

Rule #1: the internet is unreliable

Why are mobile apps built with internet dependencies? Two main reasons:

    1. The assumption that connectivity will always be available and fast, combined with the prevalence of internet-based resources like RESTful APIs and cloud backends, has made building internet dependent apps an easy development choice.
    2. The assumption that offline-first requirements do not apply to metropolitan locales; i.e., that they only apply to exotic, isolated, and hyper-remote use cases such as energy exploration, hard rock mining or wilderness rescue operations – cases where the app must operate in a complete internet-dead zone for extended periods of time.

These assumptions have led to the development of scores of mobile apps that cannot operate without an internet connection. Woe be to the user of such an application when it’s needed and no network is available!

Offline-first should be default, not niche

The very nature of mobile apps – that they run on mobile devices – means they are constantly moving from place to place and could lose network coverage at any time, even in the middle of the most modern cities on earth. Users go into subways, elevators, underground parking structures and tunnels, places where the briefest of dropped connections can render internet dependent apps unusable.

We’ve all been there: you’re at that crucial scene in a streaming movie, or you need to just hit send on that critical email, or worst of all it’s 2am and you need that rideshare from the airport…but the internet has other plans!

If these scenarios sound familiar, then you understand the frustration users go through whenever their apps fail from lack of connectivity.

And any expectation that this type of experience would be tolerated is misguided. In fact 70% of mobile app users will abandon an app that takes too long to load, and 84% of app users will abandon an app if it fails just two times, and those are just the sorts of issues that happen with internet dependent apps when the connection is interrupted.

What’s needed is a development mindset shift that does not plan for solid internet connectivity and treat disruptions as an error, but rather that expects the inherent unreliability of the internet and develops around it. In other words, for the fastest most reliable mobile apps, you should always build offline-first.

The critical components of an offline-first mobile app

The most important aspect of developing an offline-first mobile app is in how you handle data. If you want to remove internet dependencies, you need to store and process data local to the app. But you also need to make sure data can be shared with other users, and that any changes to data are reflected instantly and accurately throughout the app ecosystem.

In short, you need:

    • Local data processing – data persistence on the mobile device to maintain app availability in cases of no network. And because the data is local, it adds the benefit of real-time responsiveness.
    • Cloud data processing – in an offline-first model, the cloud still plays a vital role of being the central aggregation point for app data.
    • Data synchronization – sync data between app clients and the cloud to ensure data consistency and integrity for the app ecosystem.

Let’s take a closer look at the critical components…

Local data processing

To maintain app availability when a network is not available you need to store data locally. For this, some cloud database vendors’ mobile solutions offer on-device temporary data caching, where writes are collected and held in queue until connectivity is restored and they can be committed to the backend cloud database. However, this approach can cause problems if the app is offline for too long, because as the queue grows it can begin to impact app performance. Temporary caching also imposes a strict limit on how much data can be collected  – if the limit is exceeded you begin to risk data loss.

Unlike a temporary cache, an embedded database is more resilient, secure, and efficient in processing because it’s designed for high velocity and long term data storage. An embedded database should be the first choice for offline first mobile apps. The ideal embedded database technology includes:

    • Support for on-device backups to provide failover and minimize risk of data loss
    • The ability to deploy pre-built databases for faster app startup
    • Asynchronous database change notifications to enable reactive workflows
    • An intuitive, easy-to-use SDK for your preferred programing languages and platforms
    • Full SQL support
    • Built-in search

Cloud data processing

In an offline-first environment, a cloud database still serves as the mothership backend for mobile applications. For the most flexibility and scale, NoSQL JSON-document databases are an ideal choice because they are distributed and designed for high availability and fault tolerance. And the JSON document storage model is far less rigid than relational databases, making them easier and faster to change which accelerates development. The ideal cloud database technology includes:

    • Key-value, indexing, full-text search, analytics, time-series, and eventing built in
    • Full SQL support
    • Automatic sharding, automatic failover, and automatic replication
    • Hosted OR self-managed options

Data synchronization

A crucial piece of the offline first app puzzle is sharing data changes with other app clients. Suppose a user updates key information like a price or forecast number, you must ensure that everyone else using the app sees that updated information. For this you need to make sure your mobile app can synchronize data automatically.

While it may seem simple, building data sync for mobile apps is inherently complex, so resist the urge to try and do it yourself. Many dev teams start out innocently enough attempting to build their own sync solution, only to fail after wasting tremendous amounts of development time that could have been better spent on the core application. This is because sync is more than just replicating data, it’s making sure that it’s done securely, accurately, efficiently and instantly every time. Don’t build data sync yourself, look for a database that already offers mobile sync. The ideal sync technology includes:

    • Built-in conflict resolution
    • Secure access
    • Bi-directional sync
    • Network status monitoring to handle connectivity disruptions
    • Peer-to-peer data synchronization independent of internet connectivity
    • Delta-sync, sync only data that has changed
    • Filters and data partitioning to route and isolate data with precision

Fully assembled, the offline-first app architecture would look something like this:

With these critical components in place, you have the ability to develop mobile apps that are impervious to network slowness or failure.

So, where does one start? With a mobile database platform designed for offline-first apps.

Couchbase Mobile: the best choice for offline-first apps

Couchbase Mobile is a robust and mature mobile database platform built specifically to enable faster and more reliable mobile apps. It elegantly supports the offline-first architecture by providing the required critical components, including:

    • Couchbase Lite – An embedded mobile NoSQL database with support for SQL, built-in peer-to-peer sync, and broad mobile platform support.
    • Couchbase Capella – A fully managed cloud NoSQL database-as-a-service (DBaaS) with SQL, search, analytics, and eventing support.
    • Capella App Services – Fully managed service for bidirectional sync, authentication, and access control for mobile and edge apps.

Capella App Services provides websockets-based synchronization of data between the backend Capella DBaaS and Couchbase Lite embedded apps on edge devices. With App Services, data changes are instantly and automatically replicated across the app ecosystem as connectivity allows, while during network disruptions, apps continue to operate thanks to the embedded Couchbase Lite database.

Conclusion

Building offline-first not only makes apps impervious to internet slowness and outages, it provides a superior experience for users, and so should be a de-facto design model for modern mobile apps.

To deliver the fastest, most reliable mobile apps, you should always build offline-first with Couchbase Mobile.

    • Learn more about Couchbase Mobile here
    • Try Couchbase Capella for FREE
    • Get the Couchbase Mobile sample app

Author

Posted by Mark Gamble, Dir Product & Solutions Mktg, Couchbase

I am a passionate product marketer with a technical and solution consulting background and 20+ years of experience in Enterprise and Open Source technology. I have launched several database and analytic solutions throughout my career, and have worked with customers across a wide variety of industries including Financial Services, Automotive, Hospitality, High-Tech and Healthcare. I have particular expertise in analytics and AI, love all things data, and am an emphatic supporter of data-for-good initiatives.

Leave a reply