I was recently honored to co-present on a webcast with my colleague and good friend, Aaron LaBeau, Sr. Developer Advocate at Couchbase. Aaron has nearly 30 years of development experience and specializes in building mobile apps, and so seemed the perfect subject matter expert to join our session titled Database Strategies for Mobile and IoT Apps – Why REST won’t cut it anymore.
In the program, we set out to uncover the hurdles that developers face when building mobile apps using REST APIs for data, and then explore an alternative approach that not only eliminates the hurdles, it makes apps even better: a mobile database platform.
During the discussion, we made the point that while there are more devices and users than ever before, simply producing an app is no guarantee that it will be a success. In fact, the vast majority of apps are uninstalled within the first 30 days of use for reasons such as slow performance, long startups, lost data and crashes. And many of these problems are because of data, or more specifically, how the apps access and handle data.
Top 5 REST API Pain Points
Mobile developers that use REST APIs for accessing and modifying data are subject to challenges that impact the performance and availability of their applications. In his remarks, Aaron talked about five specific “REST API pain points” that he has encountered over the years on various projects:
Reusing “bloated” REST APIs makes apps inefficient: here the discussion focused on reasons why REST APIs intended for a web app should not be repurposed for mobile apps.
Lack of schema and data type validation: a lack of typing and validation in REST can cause mismatches in how data is sent and how it’s expected to be received between the app and the API, which can lead to a crash.
Back-and-forth data transformation: the need to constantly transform data between the app, the REST API and the backend database – for each request – makes code complex and leaves more room for error.
Translating business domain to transport model: here Aaron talked about the frustration of creating an elegant and complex domain model that fits your app to a tee, only to have to wrap it to fit the REST API, losing all of its richness and expressiveness.
Dealing with an inherently unreliable Internet: REST depends on the internet, and as such, so do your apps when they use REST. There are many potential points of failure introduced by network issues, and developers have to implement the communication logic and error handling themselves, which can make even the simplest of tasks extremely complex.
Mobile database platform to the rescue
With the pain points covered, we turned the discussion to an alternative approach to data access: a database platform built for mobile apps.
A mobile database platform is intended to simplify data handling for apps, as well as work around the inherent unreliability of the internet.
In our discussion we described how a mobile database extends data storage and processing from the cloud to the edge, including onto the device.
We explored how it can eliminate the REST pain points, reduce internet dependencies and speed up apps with local data processing – all without sacrificing consistency – by providing:
- Local data storage: by embedding the database directly to apps, it runs locally on-device and so eliminates the need for an internet connection to access data, improving uptime and reducing latency.
- Flexible data models: if your app development follows the domain model, and you want flexibility instead of relational rigidity, a JSON document database is a great mobile database option.
- Data synchronization: data synchronization is essential for integrity, accuracy, security and a good user experience. It can also make app updates easier and more foolproof.
Couchbase Mobile in action
To show the power of a mobile database platform, we then turned to a live demonstration of Simple Data Sync, the Couchbase Mobile powered sample app for iOS that syncs data between other devices both with internet via the cloud, and even without internet via peer-to-peer.
The demo was a highlight of the session, especially the part where Aaron synchronized data from his iPhone to my iPhone via the cloud, then my iPhone synchronized with my simulator which was NOT on the Internet. This showed off Couchbase Mobile’s data sync capabilities in a simple way, and we explained how the sync functionality applies to use cases like gaming, healthcare, restaurant POS, airline in-flight services and more.
We wrapped up the session by explaining the Couchbase Mobile product stack:
- Couchbase Capella: A fully managed distributed NoSQL cloud database-as-a-service (DBaaS) that supports SQL, search, eventing and analytics
- Capella App Services: Fully managed services for bidirectional sync, authentication and access control for mobile and edge apps
- Couchbase Lite: A lightweight embeddable version of the Couchbase database
Capella App Services connects the stack, synchronizing data between the backend Capella DBaaS and Couchbase Lite running on edge devices as connectivity allows, while during network disruptions apps continue to operate thanks to local data processing.
As a takeaway for all the developers in attendance, we provided a link to a 4 part code review video series that goes behind the scenes of the Simple Data Sync demo app in short 10 minute clips.
In the series, Wayne Carter – the developer of the app – dives into the code and explains how he built the sync features using Couchbase Mobile.