$30 off During Our Annual Pro Sale. View Details »

Couchbase Lite OSCON

Couchbase Lite OSCON

Lightweight embedded database for iOS and Android. This presentation focussed on the data structures you need to create a reliable mobile sync engine.

Chris Anderson

July 24, 2013
Tweet

More Decks by Chris Anderson

Other Decks in Technology

Transcript

  1. Lite

    View Slide

  2. Sync  is  the  Future  of  Mobile  Data

    View Slide

  3. What  is  Sync?
    Lite

    View Slide

  4. Data  Structures

    View Slide

  5. Collec9on  Sync  &
    Conflict  Management

    View Slide

  6. Collec9on  Sync
    •Brute  Force
    •Merkle  Trees
    •Sparse  Sequences

    View Slide

  7. Ini9al  Sync  
    3
    1 2
    5
    4
    A B
    3
    1 2
    5
    4

    View Slide

  8. Brute  Force
    3
    1 2
    5
    4
    A B
    3ʹ′
    1 2ʹ′
    5ʹ′
    4
    3ʹ′
    1 2ʹ′
    5ʹ′
    4

    View Slide

  9. Merkle  Trees
    3
    1 2
    5
    4
    A B
    1
    5ʹ′
    4
    3ʹ′
    2ʹ′
    5ʹ′
    3ʹ′
    2ʹ′

    View Slide

  10. Sparse  Sequences
    3
    1 2
    5
    4
    A B
    1
    5ʹ′
    4
    3ʹ′
    2ʹ′
    5ʹ′
    3ʹ′
    2ʹ′

    View Slide

  11. Sparse  Sequences  allow  Subset  Sync
    2
    4
    A B
    1
    5ʹ′
    4
    3ʹ′
    2ʹ′
    2ʹ′
    3
    1
    5
    C
    5ʹ′
    3ʹ′

    View Slide

  12. Collec9on  Sync
    •Brute  Force
    •Merkle  Trees
    •Sparse  Sequences

    View Slide

  13. Vector  Clocks
    • Scale  with  the  #  of  processes  upda9ng  an  item

    View Slide

  14. Revision  Trees
    {counter,  content  hash}
    4-­‐3a14f7d8
    5-­‐d7ad89bd
    4 4 4
    3 3 3
    2 2 2
    3

    View Slide

  15. Revision  Trees
    1
    2
    3
    1
    2
    3
    4 4

    View Slide

  16. Revision  Trees
    1
    2
    3
    1
    2
    3
    4 4
    4

    View Slide

  17. Revision  Trees
    1
    2
    3
    1
    2
    3
    4
    4 4

    View Slide

  18. Revision  Trees
    1
    2
    3
    4
    1
    2
    3
    4
    4
    4

    View Slide

  19. Revision  Trees
    1
    2
    3
    4
    4
    1
    2
    3
    4
    4

    View Slide

  20. Revision  Trees
    1
    2
    3
    1
    2
    3
    1
    2
    3
    4
    4
    4
    4 4
    3
    4

    View Slide

  21. Revision  Trees
    1
    2
    3
    1
    2
    1
    2
    3
    4
    4
    4
    4 4
    3
    3
    4

    View Slide

  22. Revision  Trees
    1
    2
    3
    1
    2
    1
    2
    3
    4
    4
    4
    4 4
    3
    3
    4
    5
    4

    View Slide

  23. Revision  Trees
    1
    2
    3
    1
    2
    1
    2
    3
    4
    4 4
    3
    3
    4
    5 5
    4 4

    View Slide

  24. Revision  Trees
    1
    2
    3
    1
    2
    1
    2
    4
    4
    3
    3
    4
    5 5
    3
    3
    4
    4
    5
    4 4

    View Slide

  25. Conflict  Detec9on  and  Management
    •Vector  Clocks
    •Revision  Trees

    View Slide

  26. Couchbase  Lite

    View Slide

  27. Couchbase  Lite
    Dalvik Cocoa
    Couchbase  
    Lite Couchbase  
    Lite
    • NoSQL
    ­ JSON  documents
    ­ binary  a7achments
    ­ views  and  queries
    • Lightweight
    ­ na;ve  Objec;ve-­‐C  /  Java
    ­ less  than  1MB  library  size
    • Robust
    ­ SQLite  storage  engine  is  part  of  the  
    opera;ng  system  standard  library
    “The  best  database  for  mobile  devices.”

    View Slide

  28. Sync  Gateway
    Sync  Gateway
    App  Server
    Access  
    Control
    Push  
    No;fica;ons
    etc
    Couchbase  Server
    • Sync  Engine
    ­ HTTP  sync  protocol
    ­ Compa;ble  with  lots  of  clients
    • Access  Control
    ­ User  management
    ­ Channels
    ­ Applica;on  override!
    • Easy  to  deploy
    ­ Go  run;me  works  on  all  supported  
    Couchbase  Server  plaQorms
    ­ Buil;n  lightweight  storage  for  
    development  mode

    View Slide

  29. Sync  Gateway
    App  Server
    Access  
    Control
    HTTP  /  JSON
    Sync
    Couchbase  Server
    Dalvik Cocoa
    Couchbase  
    Lite Couchbase  
    Lite
    Push  
    No;fica;ons
    etc

    View Slide

  30. One Page of Cloud

    View Slide

  31. View Slide

  32. View Slide

  33. One  Page  of  Cloud

    View Slide

  34. Data Routing
    Data Data

    View Slide

  35. Data Routing
    Data
    Data
    Data

    View Slide

  36. Data Routing
    Data
    Data
    Data
    Data

    View Slide

  37. Data Routing
    Data
    D
    ata
    Data
    Data
    Data

    View Slide

  38. Data Routing
    Data
    D
    ata
    Data
    Data
    Data
    Data

    View Slide

  39. Data Routing
    Data
    Data
    Data
    Data
    Data
    Data

    View Slide

  40. Demo  -­‐  CouchChat

    View Slide

  41. New  PhoneGap  Plugin
    haps://github.com/couchbaselabs/LiteGap
    plugman  -­‐-­‐platform  $PLATFORM  -­‐-­‐project  ~/MyPhoneGapApp  -­‐-­‐plugin  https://github.com/couchbaselabs/LiteGap.git

    View Slide

  42. Use  Cases

    View Slide

  43. Medical  Records
    • NoSQL  flexible  schema  integrates  well  with  exis9ng  systems
    • Staff  can  carry  data  with  them  to  pa9ents
    • WiFi  limited  in  hospitals

    View Slide

  44. Retail  /  Loyalty  /  Point  of  Sale
    •  

    View Slide

  45. Airline
    • Flight  plans
    • Passenger  manifest  and  purchases
    • Mobile  to  mobile  sync  in  the  air
    • Connects  to  cloud  on  the  ground

    View Slide

  46. Personal  Data
    Timebox by Pepper Networks
    • contacts,  photos,  etc

    View Slide

  47. Games  and
    Social  Media
    • Fine  grained  sharing  &  messaging
    • Great  for  turn-­‐based  games,  chat

    View Slide

  48. Collabora9on  “Groupware”
    • Con9nuous  sync
    • Conflict  detec9on
    • Rich  data  model
    h7p://www.hubapp.com/

    View Slide

  49. Thank  You
    Chris  Anderson      @jchris
    haps://groups.google.com/forum/#!forum/mobile-­‐couchbase
    haps://github.com/couchbaselabs/LiteGap
    haps://github.com/couchbase/couchbase-­‐lite-­‐ios
    haps://github.com/couchbase/couchbase-­‐lite-­‐android

    View Slide