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

Introduction To TouchDB

Edbd5f1c2f535b14165ae883fa7c3f37?s=47 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.

Edbd5f1c2f535b14165ae883fa7c3f37?s=128

Jens Alfke

September 17, 2012
Tweet

Transcript

  1. 1 TouchDB Jens  Al(e Mobile  Engineering  Peer TouchDB

  2. 1 TouchDB Jens  Al(e Mobile  Engineering  Peer TouchDB I write

    iOS & Mac code
  3. 1 TouchDB Jens  Al(e Mobile  Engineering  Peer TouchDB NoSQL database

    company I write iOS & Mac code
  4. 2 WHAT  IS  THIS  I  DON’T  EVEN TouchDB

  5. 2 WHAT  IS  THIS  I  DON’T  EVEN TouchDB C

  6. 2 WHAT  IS  THIS  I  DON’T  EVEN TouchDB

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

     NoSQL  Database  &  Sync  Engine
  8. TouchDB 3 TouchDB  Is

  9. TouchDB 3 TouchDB  Is • An  easy-­‐to-­‐use,  scalable  data  storage

     library – No  finicky  schema – “Property-­‐lists  on  steroids!”  (aka  all-­‐JSON)
  10. 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
  11. 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
  12. 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
  13. 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
  14. 4 TAKE  THE  NETWORK OUT  OF  THE  CRITICAL  PATH!

  15. TouchDB The  CriNcal  Path:  Launch,  Open,  Save 5

  16. My  Cool  App TouchDB The  CriNcal  Path:  Launch,  Open,  Save

    5
  17. My  Cool  App TouchDB The  CriNcal  Path:  Launch,  Open,  Save

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

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

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

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

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

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

    Network
  29. TouchDB 8.  Networks  Are  Not  Homogeneous 12 Your  iOS  App

    Network Your Android App x_x ?
  30. TouchDB 8.  Networks  Are  Not  Homogeneous 12 Your  iOS  App

    Network Your Android App x_x ? Your Windows App x_x ?
  31. 13 TAKE  THE  NETWORK OUT  OF  THE  CRITICAL  PATH!

  32. TouchDB Take  The  Network  Out  Of  The  CriNcal  Path 14

    Your  App Network DB Server DB
  33. TouchDB Take  The  Network  Out  Of  The  CriNcal  Path 14

    Your  App DB Server DB
  34. TouchDB Take  The  Network  Out  Of  The  CriNcal  Path 14

    Your  App DB Server DB
  35. TouchDB Take  The  Network  Out  Of  The  CriNcal  Path 14

    Your  App DB Server DB
  36. TouchDB Take  The  Network  Out  Of  The  CriNcal  Path 14

    Your  App DB Server DB
  37. TouchDB Take  The  Network  Out  Of  The  CriNcal  Path 14

    Your  App DB Server DB Data Sync Engine
  38. TOUCHDB  IS  A  DATA-­‐SYNC  ENGINE 15

  39. TouchDB TouchDB  Is  A  Data  Sync  Engine 16

  40. TouchDB TouchDB  Is  A  Data  Sync  Engine 16 • It

     manages  “documents” – Arbitrary  JSON  content – Can  contain  large  binary  afachments – Conflict  management  (versioning)
  41. 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
  42. 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
  43. TouchDB TouchDB’s  Server-­‐Side  Partner:  CouchDB 17 – Same  data  model

    – CompaNble  API – Common  sync  protocol
  44. TouchDB Running  CouchDB 18

  45. TouchDB Running  CouchDB 18

  46. TouchDB Running  CouchDB 18 $ sudo apt-get couchdb

  47. TouchDB Running  CouchDB 18 $ sudo apt-get couchdb

  48. TouchDB Running  CouchDB 18 $ sudo apt-get couchdb

  49. TouchDB Syncing  With  CouchDB 19 Your  App TouchDB

  50. TouchDB Syncing  With  CouchDB 19 Your  App TouchDB 1.  Create

     a  local  database
  51. TouchDB Syncing  With  CouchDB 19 Your  App TouchDB 1.  Create

     a  local  database
  52. TouchDB Syncing  With  CouchDB 19 Your  App TouchDB 1.  Create

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

     Create  a  local  database 2.  Set  the  remote  URL  to  sync  with
  54. 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
  55. 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
  56. 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
  57. 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
  58. 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
  59. 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
  60. 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
  61. 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
  62. 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
  63. 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
  64. 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
  65. 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
  66. TouchDB Why  TouchDB  Is  Awesome 21

  67. TouchDB Why  TouchDB  Is  Awesome 21 • Flexible  no-­‐schema  NoSQL

     data  store
  68. TouchDB Why  TouchDB  Is  Awesome 21 • Flexible  no-­‐schema  NoSQL

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

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

     data  store • Easy  data  networking  &  syncing • All  open  source,  no  proprietary  layers • Cross-­‐plaporm
  71. 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
  72. 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
  73. AND  NOW A  WORD  FROM  OUR  SPONSOR 22

  74. 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!
  75. 24 TouchDB RESOURCES touchdb.org

  76. 24 TouchDB RESOURCES touchdb.org github.com/couchbaselabs/TouchDB-­‐iOS

  77. 24 TouchDB RESOURCES touchdb.org github.com/couchbaselabs/TouchDB-­‐iOS couchbase.com

  78. 24 TouchDB RESOURCES touchdb.org couchdb.apache.org github.com/couchbaselabs/TouchDB-­‐iOS couchbase.com