Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction To TouchDB

Jens Alfke
September 17, 2012

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
Tweet

More Decks by Jens Alfke

Other Decks in Technology

Transcript

  1. 2 WHAT  IS  THIS  I  DON’T  EVEN TouchDB A  Mobile

     NoSQL  Database  &  Sync  Engine
  2. TouchDB 3 TouchDB  Is • An  easy-­‐to-­‐use,  scalable  data  storage

     library – No  finicky  schema – “Property-­‐lists  on  steroids!”  (aka  all-­‐JSON)
  3. 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
  4. 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
  5. 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
  6. 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
  7. My  Cool  App TouchDB The  CriNcal  Path:  Launch,  Open,  Save

    5 D A T A blah blah blah blah blah blah blah blah
  8. My  Cool  App TouchDB The  CriNcal  Path:  Launch,  Open,  Save

    5 D A T A blah blah blah blah blah blah blah blah Saving…
  9. 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
  10. 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
  11. TouchDB The  Network  On  The  CriNcal  Path 6 Your  App

    D A T A blah blah blah blah blah blah blah blah
  12. TouchDB The  Network  On  The  CriNcal  Path 6 Your  App

    Network D A T A blah blah blah blah blah blah blah blah
  13. 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
  14. TouchDB 1.  Networks  Are  Unreliable 8 Your  App  :( Notwork

    D A T A blah blah blah blah blah blah blah blah
  15. 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/
  16. TouchDB 3.  Networks  Have  Unpredictable  Bandwidth 10 Your  App  :|

    Nitwork D A T A blah blah blah blah blah blah blah blah
  17. 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!
  18. TouchDB 8.  Networks  Are  Not  Homogeneous 12 Your  iOS  App

    Network Your Android App x_x ? Your Windows App x_x ?
  19. TouchDB TouchDB  Is  A  Data  Sync  Engine 16 • It

     manages  “documents” – Arbitrary  JSON  content – Can  contain  large  binary  afachments – Conflict  management  (versioning)
  20. 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
  21. 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
  22. TouchDB Syncing  With  CouchDB 19 Your  App TouchDB 1.  Create

     a  local  database 2.  Set  the  remote  URL  to  sync  with
  23. TouchDB Syncing  With  CouchDB 19 Your  App Sync TouchDB 1.

     Create  a  local  database 2.  Set  the  remote  URL  to  sync  with
  24. 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
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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
  36. TouchDB Why  TouchDB  Is  Awesome 21 • Flexible  no-­‐schema  NoSQL

     data  store • Easy  data  networking  &  syncing
  37. TouchDB Why  TouchDB  Is  Awesome 21 • Flexible  no-­‐schema  NoSQL

     data  store • Easy  data  networking  &  syncing • All  open  source,  no  proprietary  layers
  38. TouchDB Why  TouchDB  Is  Awesome 21 • Flexible  no-­‐schema  NoSQL

     data  store • Easy  data  networking  &  syncing • All  open  source,  no  proprietary  layers • Cross-­‐plaporm
  39. 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
  40. 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
  41. 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!