Share
Embed
Introduction To TouchDB
A brief high-level introduction to TouchDB, and more generally why you want to keep the network off your app's critical path by using a sync engine to do the networking for you.
Originally presented at the Silicon Valley iOS Developers' Meetup.
Jens Alfke
September 17, 2012
Transcript
78 slides
-
1 TouchDB Jens Al(e Mobile Engineering Peer TouchDB I write
iOS & Mac code -
1 TouchDB Jens Al(e Mobile Engineering Peer TouchDB NoSQL database
company I write iOS & Mac code -
2 WHAT IS THIS I DON’T EVEN TouchDB A Mobile
NoSQL Database & Sync Engine -
TouchDB 3 TouchDB Is • An easy-‐to-‐use, scalable data storage
library – No finicky schema – “Property-‐lists on steroids!” (aka all-‐JSON) -
TouchDB 3 TouchDB Is • An easy-‐to-‐use, scalable data storage
library – No finicky schema – “Property-‐lists on steroids!” (aka all-‐JSON) • A powerful data-‐sync engine – AutomaNc caching & offline support – Share content with other users -
TouchDB 3 TouchDB Is • An easy-‐to-‐use, scalable data storage
library – No finicky schema – “Property-‐lists on steroids!” (aka all-‐JSON) • A powerful data-‐sync engine – AutomaNc caching & offline support – Share content with other users • OpNmized for mobile apps – Under 500k code size (iOS) – IniNalizes in < 100ms -
TouchDB 3 TouchDB Is • An easy-‐to-‐use, scalable data storage
library – No finicky schema – “Property-‐lists on steroids!” (aka all-‐JSON) • A powerful data-‐sync engine – AutomaNc caching & offline support – Share content with other users • OpNmized for mobile apps – Under 500k code size (iOS) – IniNalizes in < 100ms • Open Source -
TouchDB 3 TouchDB Is • An easy-‐to-‐use, scalable data storage
library – No finicky schema – “Property-‐lists on steroids!” (aka all-‐JSON) • A powerful data-‐sync engine – AutomaNc caching & offline support – Share content with other users • OpNmized for mobile apps – Under 500k code size (iOS) – IniNalizes in < 100ms • Open Source • A be*er approach to networking for apps -
My Cool App TouchDB The CriNcal Path: Launch, Open, Save
5 D A T A blah blah blah blah blah blah blah blah -
My Cool App TouchDB The CriNcal Path: Launch, Open, Save
5 D A T A blah blah blah blah blah blah blah blah Saving… -
My Cool App TouchDB The CriNcal Path: Launch, Open, Save
5 D A T A blah blah blah blah blah blah blah blah Saving… Network Error -
My Cool App TouchDB The CriNcal Path: Launch, Open, Save
5 D A T A blah blah blah blah blah blah blah blah Saving… Network Error -
TouchDB The Network On The CriNcal Path 6 Your App
D A T A blah blah blah blah blah blah blah blah -
TouchDB The Network On The CriNcal Path 6 Your App
Network D A T A blah blah blah blah blah blah blah blah -
TouchDB Fallacies Of Distributed CompuNng 7 • “EssenNally everyone, when
they first build a distributed applicaNon, makes the following eight assumpNons. All prove to be false in the long run and all cause big trouble and painful learning experiences.” – 1. The network is reliable. – 2. Latency is zero. – 3. Bandwidth is infinite. – 4. The network is secure. […] – 8. The network is homogeneous. Peter Deutsch, Sun Microsystems, 1994 Wikipedia: Fallacies_of_Distributed_CompuJng -
TouchDB 1. Networks Are Unreliable 8 Your App :( Notwork
D A T A blah blah blah blah blah blah blah blah -
TouchDB 2. Cell Networks Have High Latency 9 Your App
:p Knotwork D A T A blah blah blah blah blah blah blah blah igvita.com/2012/07/19/latency-‐the-‐new-‐web-‐performance-‐boTleneck/ -
TouchDB 3. Networks Have Unpredictable Bandwidth 10 Your App :|
Nitwork D A T A blah blah blah blah blah blah blah blah -
D A T A blah blah blah blah secret secret
blah blah TouchDB 4. Networks & Servers Can Be Insecure 11 Your App :o Network Secure! SSL! -
TouchDB 8. Networks Are Not Homogeneous 12 Your iOS App
Network Your Android App x_x ? -
TouchDB 8. Networks Are Not Homogeneous 12 Your iOS App
Network Your Android App x_x ? Your Windows App x_x ? -
TouchDB Take The Network Out Of The CriNcal Path 14
Your App Network DB Server DB -
TouchDB Take The Network Out Of The CriNcal Path 14
Your App DB Server DB -
TouchDB Take The Network Out Of The CriNcal Path 14
Your App DB Server DB -
TouchDB Take The Network Out Of The CriNcal Path 14
Your App DB Server DB -
TouchDB Take The Network Out Of The CriNcal Path 14
Your App DB Server DB -
TouchDB Take The Network Out Of The CriNcal Path 14
Your App DB Server DB Data Sync Engine -
TouchDB TouchDB Is A Data Sync Engine 16 • It
manages “documents” – Arbitrary JSON content – Can contain large binary afachments – Conflict management (versioning) -
TouchDB TouchDB Is A Data Sync Engine 16 • It
manages “documents” – Arbitrary JSON content – Can contain large binary afachments – Conflict management (versioning) • It lets you query them – Map/reduce “views” – Schemaless, highly flexible -
TouchDB TouchDB Is A Data Sync Engine 16 • It
manages “documents” – Arbitrary JSON content – Can contain large binary afachments – Conflict management (versioning) • It lets you query them – Map/reduce “views” – Schemaless, highly flexible • It syncs them for you – Whenever the network’s available – All data or filtered – ConNnuous, live updates without blocking your UI -
TouchDB TouchDB’s Server-‐Side Partner: CouchDB 17 – Same data model
– CompaNble API – Common sync protocol -
TouchDB Syncing With CouchDB 19 Your App TouchDB 1. Create
a local database -
TouchDB Syncing With CouchDB 19 Your App TouchDB 1. Create
a local database -
TouchDB Syncing With CouchDB 19 Your App TouchDB 1. Create
a local database 2. Set the remote URL to sync with -
TouchDB Syncing With CouchDB 19 Your App Sync TouchDB 1.
Create a local database 2. Set the remote URL to sync with -
TouchDB Syncing With CouchDB 19 Your App Sync TouchDB 1.
Create a local database 2. Set the remote URL to sync with 3. Populate your UI from the local data -
TouchDB Syncing With CouchDB 19 Your App Sync TouchDB D
A T A blah blah blah blah blah blah blah blah 1. Create a local database 2. Set the remote URL to sync with 3. Populate your UI from the local data -
TouchDB Syncing With CouchDB 19 Your App Sync TouchDB D
A T A blah blah blah blah blah blah blah blah 1. Create a local database 2. Set the remote URL to sync with 3. Populate your UI from the local data 4. Use KVO & bindings to update the UI -
TouchDB Syncing With CouchDB 19 Your App Sync TouchDB D
A T A blah blah blah blah blah blah blah blah 1. Create a local database 2. Set the remote URL to sync with 3. Populate your UI from the local data 4. Use KVO & bindings to update the UI -
TouchDB Syncing With CouchDB 19 Your App Sync TouchDB D
A T A blah blah blah blah blah blah blah blah 1. Create a local database 2. Set the remote URL to sync with 3. Populate your UI from the local data 4. Use KVO & bindings to update the UI -
TouchDB Syncing With CouchDB 19 Your App Sync TouchDB D
A T A blah blah blah blah blah blah blah blah 1. Create a local database 2. Set the remote URL to sync with 3. Populate your UI from the local data 4. Use KVO & bindings to update the UI 5. Write changes back to the local db -
TouchDB Syncing With CouchDB 19 Your App Sync TouchDB D
A T A blah blah blah blah blah blah blah blah 1. Create a local database 2. Set the remote URL to sync with 3. Populate your UI from the local data 4. Use KVO & bindings to update the UI 5. Write changes back to the local db TouchDB -
TouchDB Syncing With CouchDB 19 Your App Sync TouchDB D
A T A blah blah blah blah blah blah blah blah 1. Create a local database 2. Set the remote URL to sync with 3. Populate your UI from the local data 4. Use KVO & bindings to update the UI 5. Write changes back to the local db TouchDB -
TouchDB Peer-‐to-‐Peer Syncing With TouchDB 20 Your App Sync TouchDB
D A T A blah blah blah blah blah blah blah blah TouchDB -
Your App D A T A blah blah blah blah
blah blah blah blah TouchDB Peer-‐to-‐Peer Syncing With TouchDB 20 Your App Sync TouchDB D A T A blah blah blah blah blah blah blah blah TouchDB -
Your App D A T A blah blah blah blah
blah blah blah blah TouchDB Peer-‐to-‐Peer Syncing With TouchDB 20 Your App Sync TouchDB D A T A blah blah blah blah blah blah blah blah TouchDB -
Your App D A T A blah blah blah blah
blah blah blah blah TouchDB Peer-‐to-‐Peer Syncing With TouchDB 20 Your App TouchDB D A T A blah blah blah blah blah blah blah blah TouchDB TouchDB Sync Sync -
TouchDB Why TouchDB Is Awesome 21 • Flexible no-‐schema NoSQL
data store • Easy data networking & syncing -
TouchDB Why TouchDB Is Awesome 21 • Flexible no-‐schema NoSQL
data store • Easy data networking & syncing • All open source, no proprietary layers -
TouchDB Why TouchDB Is Awesome 21 • Flexible no-‐schema NoSQL
data store • Easy data networking & syncing • All open source, no proprietary layers • Cross-‐plaporm -
TouchDB Why TouchDB Is Awesome 21 • Flexible no-‐schema NoSQL
data store • Easy data networking & syncing • All open source, no proprietary layers • Cross-‐plaporm • MulN-‐user -
TouchDB Why TouchDB Is Awesome 21 • Flexible no-‐schema NoSQL
data store • Easy data networking & syncing • All open source, no proprietary layers • Cross-‐plaporm • MulN-‐user • MulNple server opNons: – Hosted – Run your own – Desktop – Peer-‐to-‐peer -
23 Coming September 21, 2012 SAN FRANCISCO Featured speakers include:
Tell them I sent you and get 50% off. Use discount code: JENS. hKp://www.couchbase.com/couchconf-‐san-‐francisco That’s this Friday!