Offline First: The key to a great app experience

Stefan Kruger (stefan.kruger@uk..com) Offerings Management IBM Cloud Data Services SDKs Twitter: @xpqz

© 2015 IBM Corporation Mobile continues to explode in the enterprise

(2014) 60% of The number of The number of large companies custom mobile enterprise mobile used 3 or fewer apps will double apps is expected mobile apps1 compared to 20142 to quadruple3

85% of companies Mobile app More than half have a mobile development will of b2e apps will backlog of up outnumber PC be created by to 20 apps4 projects 4:15 the enterprise6

2014 2016 2018

© 2015 IBM Corporation 2 Some challenges we hear for delivering great mobile apps

“Mobile app users are demanding. If my app is not delivering a great experience, I need to know.”

“Mobile opens up a new set of security considerations. Our reputation is on the line”

“My users want to be even more productive. Personalization based on devices’ context is a huge opportunity.”

“I need my development teams focused on creating great app experiences, not figuring out how to store, integrate or scale data.”

© 2015 IBM Corporation 3 Make good apps great through mobile platform services

Continuous Security Contextualization Data improvement personalization

App aspect

They require constant user Outside the network’s Mobile apps must Mobile speed and scale Hard feedback, monitoring and protection, mobile apps capture, interpret and requires new integration because release of revisions and data require specific act on disparate context and database approaches governance sources in real time for app developers

Platform services to IBM MobileFirst Platform delivers rich services and then integrates them for enable your an end-to-end experience for mobile developers and operations teams apps

© 2015 IBM Corporation 4 Platform components

Continuous Security Contextualization Data improvement personalization

Quality Assurance Application Scanning Presence Insights Cloudant Data Layer • Sentiment analysis • Development-time • Multi-sensor indoor user • Sync • In-app feedback vulnerability detection engagement • Fully managed • Crash analytics • Scalable, distributed NoSQL data store Mobile Client Access Push Notifications • Analytics • Social login

Foundation (On-premises, IaaS, PaaS)

• Native and hybrid • Runtime application security • Push notifications • Mobile-optimized development • Remote application control • Outdoor and indoor enterprise integration • Ops analytics • Flexible authentication integration location detection, and sync • Problem determination triggering, and rules • Cloudant local license and troubleshooting • Version enforcement • Application catalog

© 2015 IBM Corporation 5 Offline First

“The ability to work offline is the most important and difficult mobile feature and will be a consideration for nearly every modern application”

— Forrester Research

© 2015 IBM Corporation 6 Mobile devices are often offline

© 2015 IBM Corporation 7 Mobile networks are unreliable

+ Typical app architecture: app cannot function without live access to its backend.

+ Irritating to use!

Mobile app

Mobile data Master data store

© 2015 IBM Corporation 8 Offline first model

+ Instead, sync data to on-device database.

+ Let app talk only to local DB.

Mobile app Master data store

Device DB Data sync to device DB

© 2015 IBM Corporation 9 The app’s behaviour will be exactly the same, regardless of connectivity, which is what your users expect

© 2015 IBM Corporation 10 Bi-directional sync is hard!

+ Data can be changed by many devices simultaneously!

+ Data can be changed by other actors external to the app.

+ How do we reconcile changes and keep everything in sync?

© 2015 IBM Corporation 11 Replication should ‘just work’

+ IBM Cloudant Data Layer was designed specifically for replication

+ All nodes are equal: no master, no slave

+ No single node is the “source of truth” – they all are.

© 2015 IBM Corporation 12 Replication should ‘just work’

+ Cloudant is designed to handle network partitions

+ Cloudant already deals with the the “offline first” problem internally

+ Adding a device DB as a new in the cluster solves the sync problem “for free”

Device DB becomes a replicating node in the cloud cluster

© 2015 IBM Corporation 13 Developer chooses when to sync

Push replication Pull replication

© 2015 IBM Corporation 14 Conflicts are a natural, and expected state of data in a distributed system.

© 2015 IBM Corporation 15 In Cloudant, each document can exist in multiple versions

id: 1 id: 1 id: 1 rev: 3a rev: 4a rev: 5a id: 1 id: 1 rev: 1 rev: 2

id: 1 id: 1 id: 1 rev: 3b rev: 4b rev: 5b

© 2015 IBM Corporation 16 A Cloudant cluster can remain highly available even when faced with network partitions.

© 2015 IBM Corporation 17 A partitioned cluster

+ The cluster will respond even when partitioned

+ Once partition heals, cluster will converge

+ …but may be in a conflicted state

© 2015 IBM Corporation 18 This is called eventual consistency. The only guarantee is that the nodes will eventually converge.

You cannot safely read your writes back.

© 2015 IBM Corporation 19 A patchy, often offline mobile network is a frequently partitioned network. Ideal fit for Cloudant’s replication.

© 2015 IBM Corporation 20 Cloudant defers conflict resolution to where it makes the most sense from a business logic perspective.

© 2015 IBM Corporation 21 Mobile Data is changing

© 2015 IBM Corporation Mobile data is changing shape

4

3 Unstructured & Semi-Structured Data

2 Text, Log Files, Click Streams, Blogs, Tweets, Audio, Video, etc.

1

Structured Data Trillions of Gigabytes (Zettabytes) Gigabytes of Trillions

0 2000 2007 2014

http://www.couchbase.com/nosql-resources/what-is-no-sql

© 2015 IBM Corporation 23 JSON is the data format for mobile

+ No schema: easily accommodate new types of data

+ Database not disrupted by data structure changes

+ Natural format for unstructured or semi-structured data

JSON objects

object

{ string : value }

,

© 2015 IBM Corporation 24 The Cloudant Data Layer

© 2015 IBM Corporation 25 IBM Cloud Hero: Runkeeper

Simon Wheatcroft link: https://www.youtube.com/watch?v=IFnqBtLNoPY

Case study link: http://www-01.ibm.com/common/ssi/cgi- bin/ssialias?subtype=AB&infotype=PM&appname=SWGE_IM_DM_USEN&htmlfid=IMC14925USEN&attachment=IMC14925USEN.PDF#loaded

© 2015 IBM Corporation 26 The mobile world is global. Your data layer needs to be global, too.

© 2015 IBM Corporation 27 Cloudant can be deployed in the cloud, in your own data center, or both – as the needs of your app dictate.

Hybrid

Private Public

© 2015 IBM Corporation 28 Let IBM shoulder your operational pain. Cloudant is a fully managed service.

#sleepmore

© 2015 IBM Corporation 29 Native Mobile Development

+ Native libraries for iOS and Android, providing sync, conflict resolution and a rich query language.

+ Cordova wrappers for hybrid.

+ Fully open source, hosted on github.com/cloudant

+ Thriving community. Millions of requests per day generated from our libraries.

CDTDatastoreManager *manager = [[CDTDatastoreManager alloc] initWithDirectory:path error:&error];

datastore = [manager datastoreNamed:@"my_datastore" error:&error];

[datastore ensureIndexed:@[@"_id"] withName:@"all"];

replicatorFactory = [[CDTReplicatorFactory alloc] initWithDatastoreManager:manager];

© 2015 IBM Corporation 30 Offline first take-homes

+ Keep a subset of your data on device

+ Sync when connectivity allows, but interact with the local database

+ Store data as JSON: no upfront rigid schema

+ Home your data where it makes the most sense: • Close to your users, in the cloud • Inside your own data center, for governance or security • …or a combination

© 2015 IBM Corporation 31 The IBM Cloudant Solution

+ Cloud-based document data store built for replication

+ Global data centers

+ Highly scalable and fully managed (if so desired)

+ Mobile libraries act as a cluster node

+ Native sync libraries for iOS and Android

+ Data at rest encryption

+ Data in flight always over a secure channel

© 2015 IBM Corporation 32 Get started today

IBM MobileFirst Platform (ibm.biz/MFPlatform)

+ Get started today with IBM MobileFirst Platform https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/

+ Try our free IBM MobileFirst Platform trial on Bluemix https://console.ng.bluemix.net/catalog/ibm-mobilefirst-starter/

+ Try our free IBM Cloudant trial https://cloudant.com/sign-up/

© 2015 IBM Corporation 33 Platform components

Continuous Security Contextualization Data improvement personalization

Quality Assurance Application Scanning Presence Insights Cloudant Data Layer • Sentiment analysis • Development-time • Multi-sensor indoor user • Sync • In-app feedback vulnerability detection engagement • Fully managed • Crash analytics • Scalable, distributed NoSQL data store Mobile Client Access Push Notifications • Analytics • Social login

Foundation (On-premises, IaaS, PaaS)

• Native and hybrid • Runtime application security • Push notifications • Mobile-optimized development • Remote application control • Outdoor and indoor enterprise integration • Ops analytics • Flexible authentication integration location detection, and sync • Problem determination triggering, and rules • Cloudant local license and troubleshooting • Version enforcement • Application catalog

© 2015 IBM Corporation 34 Thank you

Stefan Kruger ([email protected]) Offerings Management, IBM Cloud Data Services SDKs

© 2015 IBM Corporation 35 Notices and Disclaimers

+ Copyright © 2015 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in any form without written permission from IBM.

+ U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM.

+ Information in these presentations (including information relating to products that have not yet been announced by IBM) has been reviewed for accuracy as of the date of initial publication and could include unintentional technical or typographical errors. IBM shall have no responsibility to update this information. THIS document is distributed "AS IS" without any warranty, either express or implied. In no event shall IBM be liable for any damage arising from the use of this information, including but not limited to, loss of data, business interruption, loss of profit or loss of opportunity. IBM products and services are warranted according to the terms and conditions of the agreements under which they are provided.

+ Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice.

+ Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual performance, cost, savings or other results in other operating environments may vary.

+ References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs or services available in all countries in which IBM operates or does business.

+ Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily reflect the views of IBM. All materials and discussions are provided for informational purposes only, and are neither intended to, nor shall constitute legal or other guidance or advice to any individual participant or their specific situation.

+ It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel as to the identification and interpretation of any relevant laws and regulatory requirements that may affect the customer’s business and any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or represent or warrant that its services or products will ensure that the customer is in compliance with any law.

© 2015 IBM Corporation 36 Notices and Disclaimers (continued)

+ Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products in connection with this publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to interoperate with IBM’s products. IBM expressly disclaims all warranties, expressed or implied, including but not limited to, the implied warranties of merchantability and fitness for a particular purpose.

+ The provision of the information contained herein is not intended to, and does not, grant any right or license under any IBM patents, copyrights, trademarks or other intellectual property right.

+ IBM, the IBM logo, ibm.com, Bluemix, Blueworks Live, CICS, Clearcase, DOORS®, Enterprise Document Management System™, Global Business Services ®, Global Technology Services ®, Information on Demand, ILOG, Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™, PureApplication®, pureCluster™, PureCoverage®, PureData®, PureExperience®, PureFlex®, pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, SoDA, SPSS, StoredIQ, Tivoli®, Trusteer®, urban{code}®, , WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies.

+ A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.

© 2015 IBM Corporation 37