SlideShare a Scribd company logo
MongoDB Mobile
Bringing the Power of MongoDB to Your Device
Matt Lord
Senior Product Manager
@mattalord
We’ve Come a Long
Way
Mobile
Is Transforming Everything
Mobile is becoming not only the new
digital hub, but also the bridge to the
physical world. That’s why mobile will
affect more than just your digital
operations — it will transform your
entire business.
Thomas Husson, Vice President and Principal
Analyst at Forrester Research
A Complete Data Platform
● Geographically distributed backend services
○ MongoDB Atlas
■ Point and click active/active global clusters
■ Effortless HA, DR, and low-latency access
○ MongoDB Stitch, Serverless Platform
■ Automatic scaling based on request volume
■ Stitch Query Anywhere
■ Stitch Functions
■ Stitch Triggers
■ Stitch Mobile Sync (coming soon)
● Geographically distributed frontend services
○ MongoDB Mobile
■ IoT and edge devices
■ iOS and Android apps
■ Supporting local offline storage
● Stitch provides a seamless bridge between them
MongoDB Mobile
The Full Stack
MongoDB Embedded SDK
● A lite version of MongoDB as a library
● C language interface to the library
● Fully passive, no background threads or tasks
MongoDB Drivers
● Swift for iOS, Java for Android
● Existing drivers, extended to support local storage
MongoDB Stitch SDK
● Access to MongoDB Stitch services from Android and iOS
● New Stitch Interfaces for on-device (local) storage
● Synchronization between local and remote
Your Mobile Application
● iOS and Android devices
● Leveraging the power of MongoDB everywhere
● Allowing you to focus on building your GREAT THING
MongoDB Mobile Storage Engine
● K/V storage on top of SQLite
● Very small disk footprint and minimal memory usage
● Energy efficient
Platform Details
Operating System OS Details CPUs Devices
iOS, tvOS 10.2+ ARM64
x86_64 (simulators)
Apple, Inc.
Android 5.0/Lollipop+ x86_64
armeabi-v7a
arm64-v8a
Any vendor
(by ABI)
Linux TBD x86_64 Any vendor
macOS X 10.10+ x86_64 Apple, Inc.
The Full Stack
MongoDB Stitch SDK
● Packages the entire mobile stack together
● Stitches the frontend and backend together
○ End-to-end Mobile SDK
○ API for local storage
○ API for remote Stitch invocation
○ API for syncing between local and remote
○ Provides a transparent bridge for applications
● iOS SDK: https://github.com/mongodb/stitch-ios-sdk/tree/v4-
alpha
● Android SDK: https://github.com/mongodb/stitch-android-
sdk/tree/v4-alpha
final StitchAppClient client = Stitch.getDefaultAppClient();
final MongoClient mongoClient = client.getServiceClient(LocalMongoDbService.ClientFactory);
MongoCollection<Document> items =
mongoClient.getDatabase(TodoItem.TODO_LIST_DATABASE).getCollection(TodoItem.TODO_LIST_COLLECTIO
N);
public void updateChecked(final ObjectId itemId, final boolean isChecked) {
final Document updateDoc = new Document("$set", new Document(TodoItem.CHECKED_KEY, isChecked));
if (isChecked) {
updateDoc.append("$currentDate", new Document(TodoItem.DONE_DATE_KEY, true));
} else {
updateDoc.append("$unset", new Document(TodoItem.DONE_DATE_KEY, ""));
}
items.updateOne(new Document(TodoItem.ID_KEY, itemId), updateDoc);
...
}
private List<TodoItem> getItems() {
final ArrayList<TodoItem> todoItems = new ArrayList<>();
for (final Document doc : items.find()) {
if (TodoItem.isTodoItem(doc)) {
final TodoItem item = new TodoItem(doc);
todoItems.add(item);
}
}
return todoItems;
}
The Full Stack
MongoDB Drivers
● Existing drivers for the given language
○ With a few extensions
■ Open a local storage instance
■ Close a local storage instance
○ Support today for Swift, Java, and C
○ Others created based on demand
● Can be tested directly
○ Swift: https://github.com/mongodb/swift-mongo-
mobile/
○ Java:
http://central.maven.org/maven2/org/mongodb/mongodb-
driver-embedded/
import MongoMobile
…
let client = MongoMobile.create(settings: MongoClientSettings [ dbPath: "test-path" ])
let coll = try client.db("test").collection("foo")
let insertResult = try coll.insertOne([ "test": 42 ])
let findResult = try coll.find([ "_id": insertResult!.insertedId ])
let docs = Array(findResult)
The Full Stack
MongoDB Embedded SDK
● Lite version of MongoDB formed into a library
○ C ABI
○ Auth, Replication, Sharding, etc. removed
○ Supports only the mobile storage engine
○ Passive: no background threads
○ Light: disk, memory, energy
● C Interface
○ Low level
○ Not designed to be used directly
○ Drivers should be extended to invoke it
● Availability
○ Builds out of MongoDB 4.0+ community tree
○ Pre-built binary packages for mobile targets
auto status = mongo_embedded_v1_status_create();
mongo_embedded_v1_init_params params;
...
auto lib = mongo_embedded_v1_lib_init(&params, status);
auto config_yaml = ...
auto instance = mongo_embedded_v1_instance_create(lib,
config_yaml, status);
auto client = mongo_embedded_v1_client_create(instance, status);
auto [inputMessage, inputMessageLen] = ...
auto [output, outputLen] = ...
int err = mongo_embedded_v1_client_invoke(client,
inputMessage, inputMessageLen,
&output, &outputLen,
status);
The Full Stack
Mobile Storage Engine
● Leverages SQLite as a K/V store
○ Single SQLite database called “mobile”
○ Table names follow the WiredTiger filesystem /
dictionary naming convention
○ Every entity you create
■ database, collection, index, ...
■ Stored in a dedicated table as K/V pairs
● Can be tested with standard mongod
./buildscripts/scons.py mongod --mobile-se=on
./build/opt/mongo/mongod --storageEngine=mobile
sqlite> .database
main: /.../mobile.sqlite
sqlite> .tables
_mdb_catalog index-1-1419396644176400596
collection-0-1419396644176400596 index-1-9204882299253173129
collection-0-9204882299253173129
sqlite> select sql from sqlite_master where name='collection-0-9204882299253173129';
CREATE TABLE "collection-0-6881873531296038739"(rec_id INT, data BLOB, PRIMARY
KEY(rec_id))
sqlite> select sql from sqlite_master where name='index-1-9204882299253173129';
CREATE TABLE "index-1-9204882299253173129"(key BLOB PRIMARY KEY, value BLOB)
sqlite> select * from `collection-0-9204882299253173129`;
rec_id data
---------- ----------
1 2
Andrew Morrow
Embedded SDK Lead
Matt Broadstone
Swift Driver Lead
Kaitlin Mahar
Swift Driver Engineer
Ross Lawley
Java Driver Lead
Q&A with the Engineers
Eric Daniels
Stitch Lead
Visit us at the MongoDB Mobile/Stitch booth!
Q&A with the Team
MongoDB Mobile: Bringing the Power of MongoDB to Your Device

More Related Content

Similar to MongoDB Mobile: Bringing the Power of MongoDB to Your Device (20)

PPTX
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
PDF
MongoDB.local Berlin: MongoDB Mobile
MongoDB
 
PPTX
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB
 
PPTX
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
PPTX
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
PPTX
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
MongoDB
 
PPTX
MongDB Mobile: Bringing the Power of MongoDB to Your Device
Matt Lord
 
PDF
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
PDF
MongoDB Mobile
MongoDB
 
PDF
MongoDB Stitch Introduction
MongoDB
 
PDF
Faites évoluer votre accès aux données avec MongoDB Stitch
MongoDB
 
PPTX
MongoDB Stitch Introduction
MongoDB
 
PPTX
MongoDB.local Dallas 2019: MongoDB Stitch Tutorial
MongoDB
 
PPTX
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB
 
PPTX
MongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB
 
PPTX
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
MongoDB
 
PDF
Building your first app with MongoDB
Norberto Leite
 
PPTX
SH 2 - SES 1 - Stitch_Workshop_TLV.pptx
MongoDB
 
PPTX
Building Your First App with MongoDB Stitch
MongoDB
 
PPTX
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
MongoDB.local Berlin: MongoDB Mobile
MongoDB
 
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB
 
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
MongoDB
 
MongDB Mobile: Bringing the Power of MongoDB to Your Device
Matt Lord
 
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
MongoDB Mobile
MongoDB
 
MongoDB Stitch Introduction
MongoDB
 
Faites évoluer votre accès aux données avec MongoDB Stitch
MongoDB
 
MongoDB Stitch Introduction
MongoDB
 
MongoDB.local Dallas 2019: MongoDB Stitch Tutorial
MongoDB
 
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB
 
MongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB
 
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
MongoDB
 
Building your first app with MongoDB
Norberto Leite
 
SH 2 - SES 1 - Stitch_Workshop_TLV.pptx
MongoDB
 
Building Your First App with MongoDB Stitch
MongoDB
 
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 

More from Matt Lord (12)

PPTX
Vitess VReplication: Standing on the Shoulders of a MySQL Giant
Matt Lord
 
PPTX
Using MySQL Containers
Matt Lord
 
PDF
Why MySQL High Availability Matters
Matt Lord
 
PDF
MySQL High Availability -- InnoDB Clusters
Matt Lord
 
PDF
Unlocking Big Data Insights with MySQL
Matt Lord
 
PDF
OpenStack Days East -- MySQL Options in OpenStack
Matt Lord
 
PDF
MySQL Group Replication - an Overview
Matt Lord
 
PDF
OpenStack and MySQL
Matt Lord
 
PPTX
MySQL DBaaS with OpenStack Trove
Matt Lord
 
PPTX
Getting Started with MySQL Full Text Search
Matt Lord
 
PPTX
Using MySQL in the Cloud
Matt Lord
 
PDF
MySQL 5.7 GIS
Matt Lord
 
Vitess VReplication: Standing on the Shoulders of a MySQL Giant
Matt Lord
 
Using MySQL Containers
Matt Lord
 
Why MySQL High Availability Matters
Matt Lord
 
MySQL High Availability -- InnoDB Clusters
Matt Lord
 
Unlocking Big Data Insights with MySQL
Matt Lord
 
OpenStack Days East -- MySQL Options in OpenStack
Matt Lord
 
MySQL Group Replication - an Overview
Matt Lord
 
OpenStack and MySQL
Matt Lord
 
MySQL DBaaS with OpenStack Trove
Matt Lord
 
Getting Started with MySQL Full Text Search
Matt Lord
 
Using MySQL in the Cloud
Matt Lord
 
MySQL 5.7 GIS
Matt Lord
 
Ad

MongoDB Mobile: Bringing the Power of MongoDB to Your Device

  • 1. MongoDB Mobile Bringing the Power of MongoDB to Your Device
  • 2. Matt Lord Senior Product Manager @mattalord
  • 3. We’ve Come a Long Way
  • 4. Mobile Is Transforming Everything Mobile is becoming not only the new digital hub, but also the bridge to the physical world. That’s why mobile will affect more than just your digital operations — it will transform your entire business. Thomas Husson, Vice President and Principal Analyst at Forrester Research
  • 5. A Complete Data Platform ● Geographically distributed backend services ○ MongoDB Atlas ■ Point and click active/active global clusters ■ Effortless HA, DR, and low-latency access ○ MongoDB Stitch, Serverless Platform ■ Automatic scaling based on request volume ■ Stitch Query Anywhere ■ Stitch Functions ■ Stitch Triggers ■ Stitch Mobile Sync (coming soon) ● Geographically distributed frontend services ○ MongoDB Mobile ■ IoT and edge devices ■ iOS and Android apps ■ Supporting local offline storage ● Stitch provides a seamless bridge between them
  • 7. The Full Stack MongoDB Embedded SDK ● A lite version of MongoDB as a library ● C language interface to the library ● Fully passive, no background threads or tasks MongoDB Drivers ● Swift for iOS, Java for Android ● Existing drivers, extended to support local storage MongoDB Stitch SDK ● Access to MongoDB Stitch services from Android and iOS ● New Stitch Interfaces for on-device (local) storage ● Synchronization between local and remote Your Mobile Application ● iOS and Android devices ● Leveraging the power of MongoDB everywhere ● Allowing you to focus on building your GREAT THING MongoDB Mobile Storage Engine ● K/V storage on top of SQLite ● Very small disk footprint and minimal memory usage ● Energy efficient
  • 8. Platform Details Operating System OS Details CPUs Devices iOS, tvOS 10.2+ ARM64 x86_64 (simulators) Apple, Inc. Android 5.0/Lollipop+ x86_64 armeabi-v7a arm64-v8a Any vendor (by ABI) Linux TBD x86_64 Any vendor macOS X 10.10+ x86_64 Apple, Inc.
  • 9. The Full Stack MongoDB Stitch SDK ● Packages the entire mobile stack together ● Stitches the frontend and backend together ○ End-to-end Mobile SDK ○ API for local storage ○ API for remote Stitch invocation ○ API for syncing between local and remote ○ Provides a transparent bridge for applications ● iOS SDK: https://github.com/mongodb/stitch-ios-sdk/tree/v4- alpha ● Android SDK: https://github.com/mongodb/stitch-android- sdk/tree/v4-alpha final StitchAppClient client = Stitch.getDefaultAppClient(); final MongoClient mongoClient = client.getServiceClient(LocalMongoDbService.ClientFactory); MongoCollection<Document> items = mongoClient.getDatabase(TodoItem.TODO_LIST_DATABASE).getCollection(TodoItem.TODO_LIST_COLLECTIO N); public void updateChecked(final ObjectId itemId, final boolean isChecked) { final Document updateDoc = new Document("$set", new Document(TodoItem.CHECKED_KEY, isChecked)); if (isChecked) { updateDoc.append("$currentDate", new Document(TodoItem.DONE_DATE_KEY, true)); } else { updateDoc.append("$unset", new Document(TodoItem.DONE_DATE_KEY, "")); } items.updateOne(new Document(TodoItem.ID_KEY, itemId), updateDoc); ... } private List<TodoItem> getItems() { final ArrayList<TodoItem> todoItems = new ArrayList<>(); for (final Document doc : items.find()) { if (TodoItem.isTodoItem(doc)) { final TodoItem item = new TodoItem(doc); todoItems.add(item); } } return todoItems; }
  • 10. The Full Stack MongoDB Drivers ● Existing drivers for the given language ○ With a few extensions ■ Open a local storage instance ■ Close a local storage instance ○ Support today for Swift, Java, and C ○ Others created based on demand ● Can be tested directly ○ Swift: https://github.com/mongodb/swift-mongo- mobile/ ○ Java: http://central.maven.org/maven2/org/mongodb/mongodb- driver-embedded/ import MongoMobile … let client = MongoMobile.create(settings: MongoClientSettings [ dbPath: "test-path" ]) let coll = try client.db("test").collection("foo") let insertResult = try coll.insertOne([ "test": 42 ]) let findResult = try coll.find([ "_id": insertResult!.insertedId ]) let docs = Array(findResult)
  • 11. The Full Stack MongoDB Embedded SDK ● Lite version of MongoDB formed into a library ○ C ABI ○ Auth, Replication, Sharding, etc. removed ○ Supports only the mobile storage engine ○ Passive: no background threads ○ Light: disk, memory, energy ● C Interface ○ Low level ○ Not designed to be used directly ○ Drivers should be extended to invoke it ● Availability ○ Builds out of MongoDB 4.0+ community tree ○ Pre-built binary packages for mobile targets auto status = mongo_embedded_v1_status_create(); mongo_embedded_v1_init_params params; ... auto lib = mongo_embedded_v1_lib_init(&params, status); auto config_yaml = ... auto instance = mongo_embedded_v1_instance_create(lib, config_yaml, status); auto client = mongo_embedded_v1_client_create(instance, status); auto [inputMessage, inputMessageLen] = ... auto [output, outputLen] = ... int err = mongo_embedded_v1_client_invoke(client, inputMessage, inputMessageLen, &output, &outputLen, status);
  • 12. The Full Stack Mobile Storage Engine ● Leverages SQLite as a K/V store ○ Single SQLite database called “mobile” ○ Table names follow the WiredTiger filesystem / dictionary naming convention ○ Every entity you create ■ database, collection, index, ... ■ Stored in a dedicated table as K/V pairs ● Can be tested with standard mongod ./buildscripts/scons.py mongod --mobile-se=on ./build/opt/mongo/mongod --storageEngine=mobile sqlite> .database main: /.../mobile.sqlite sqlite> .tables _mdb_catalog index-1-1419396644176400596 collection-0-1419396644176400596 index-1-9204882299253173129 collection-0-9204882299253173129 sqlite> select sql from sqlite_master where name='collection-0-9204882299253173129'; CREATE TABLE "collection-0-6881873531296038739"(rec_id INT, data BLOB, PRIMARY KEY(rec_id)) sqlite> select sql from sqlite_master where name='index-1-9204882299253173129'; CREATE TABLE "index-1-9204882299253173129"(key BLOB PRIMARY KEY, value BLOB) sqlite> select * from `collection-0-9204882299253173129`; rec_id data ---------- ---------- 1 2
  • 13. Andrew Morrow Embedded SDK Lead Matt Broadstone Swift Driver Lead Kaitlin Mahar Swift Driver Engineer Ross Lawley Java Driver Lead Q&A with the Engineers Eric Daniels Stitch Lead
  • 14. Visit us at the MongoDB Mobile/Stitch booth! Q&A with the Team