LowlaDB

A database for mobile applications

Introduction

LowlaDB is a JSON database with built-in mobile sync and a MongoDB-like API. It’s designed to integrate easily with today’s web databases e.g. MongoDB and popular MVC frameworks e.g. AngularJS. We have released a Javascript implementation for mobile and PC browsers and we are working on native versions for iOS and for Android that will be packaged as Cordova plugins.

Why is this needed?

To improve the user experience on mobile we often need to store, access and sync data to the user’s device. For web developers, this means having to bring in unfamiliar frameworks and platforms (e.g. Titanium, Xamarin, PouchDB/CouchDB) which come with a significant learning curve and add complexity to your project. Wouldn’t it be great if there was an easier way to create a fully-functional mobile client?

Who should use it?

Web developers working with common front end frameworks (e.g. Angular, Ember and Backbone) and back end platforms (e.g. MongoDB and Node.js) who want to add a syncing mobile client with the minimum learning curve and additional programming effort.

What can it be used for?

LowlaDB is suitable for a wide variety of applications including:

  • business-to-consumer applications (B2C)
  • business-to-employee applications (B2E)
  • much faster-responding web sites for mobile users (e.g. for microsites)

Our technical objectives for LowlaDB are :

  1. Simplicity of development
  2. Low-latency data access
  3. Offline capability
  4. Multi-platform capability
  5. Flexibility to sync to different back ends

Simplicity

LowlaDB is designed as an easy-to-program JSON database for mobile devices. The developer API for LowlaDB is based closely on MongoDB to which we’ve added a number of mobile sync functions. An overview of the API follows here, but for more details on the direction in which we intend to take the API, see the documentation for the Node.js MongoDB driver here. In addition to the basic API, LowlaDB adds extensions to support real-time data updates and wherever possible offers promise-based APIs as an alternative to callbacks.

Low latency

Mobile networks are much faster than they used to be. However, once sufficient bandwidth is available then latency becomes far more important than bandwidth in determining the responsiveness of an app.

There is a minimal improvement in page load time as mobile bandwidth increases beyond 5 Mbps, but a continuing linear improvement as latency decreases (graph from Ilya Grigorik, Google https://www.igvita.com/2012/07/19/latency-the-new-web-performance-bottleneck/ ).

Latency per Bandwidth

Graphic credit: Ilya Grigorik (Google)

Wireless internet connections have surprisingly high latency (graphic courtesy of Mobify, http://www.mobify.com/blog/web-performance-optimization/). By locating the datastore on the device, our measurements show that developers can achieve a minimum 4-fold reduction in latency time for data access compared to a wireless connection. In typical real world conditions that advantage rises to 10X or more.

Carrier Latency

Offline capability

With real-world wireless networks it is not possible to guarantee that any device will be online 100% of the time. There are many network dead spots where coverage is poor or non-existent. Networks can become overloaded at peak times resulting in loss of access. Interference from other radio sources may cause severe packet loss. Well-designed mobile apps should not block the user when their device is offline, but continue to function and then sync their data with the back end system when the network returns. LowlaDB’s goal is to make it much easier to develop this kind of application.

Multiplatform

We now carry many different types of devices – laptops, phones and tablets – each of which may be best for any given task. We want our apps to run on all of our devices and sync data automatically between them. In the future, the Internet of Things will add to this device variety. For all these reasons it’s important that LowlaDB is architected to make it easy to port to the widest possible range of platforms.

The initial release of LowlaDB is a pure Javascript implementation that runs on either IndexedDB or in memory. For IndexedDB implementations it is suitable for databases up to 20MB in size and up to 10k items, providing a rapid development cycle.

If your application needs to scale to larger databases, a later release of LowlaDB will add a specialized datastore implementaton designed to run in Cordova. Web applications built with LowlaDB will run in Cordova with no code changes required and will automatically detect and use the improved datastore. The Cordova implementation will also add features not possible in the browser such as overnight syncing.

Backend flexibility

Mobile apps are a combination of a front end running on the device and a back end running in the cloud or in an enterprise data center. These back ends are very diverse. They can be built on either SQL and NoSQL databases. They may provide a RESTful API to the front end, or some other kind of API across the network. To accommodate all of these different scenarios, LowlaDB provides a great deal of flexibility in connecting to different back ends. This is achieved by the provision of a modular adapter layer between the Lowla Syncer and the back end system.

LowlaDB Architecture

With the appropriate adapters, LowlaDB syncs data from a wide variety of back ends down to the device so that apps can always use data that is stored locally. That makes applications fast because data is always close by and reliable because they never have to worry about wireless signal strength or the availability of WiFi. In the initial implementation adapters are written in Javascript and run on Node.js, although the architecture makes provision for creating adapters in other languages.