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

Ways to Sync Data in mobile (Android)

Ways to Sync Data in mobile (Android)

981c62da5b61c6924ef2d5b7fba6efca?s=128

Selvakumar Natesan

October 29, 2013
Tweet

Transcript

  1. n ways to sync data for mobile apps Selva github.com/selvakn

    Geeknight Chennai
  2. About The Application Quick overview Transform class room teaching and

    learning Using Android Tablets For school teachers and students More effective With classroom activities And assignments · · · · · ·
  3. Challenges Share Content Assignments · Videos eBooks Documents - -

    - · Reading Quiz Short Answer Explore - - - - Inclass Activities · Discussions Comments Quick Poll Call a student (randomly) - - - -
  4. What exactly is the problem Now the technical part Push

    Content In realtime To 1000s of tablet concurrently Broadcast - sometimes To a subset of tablet - sometimes Offline Platform - Support multiple apps · · · · · · ·
  5. Setup

  6. Setup

  7. Setup

  8. Setup

  9. Poll for data changes

  10. Poll for data changes

  11. Poll for data changes

  12. Poll for data changes Pros Cons Tablet posts the content

    to server Poll for its content At regular intervals With android services The server returns only the deltas · · · · · Simplest Solution Possible Offline tablets gets the data back when online · · Createing contents Offline (Read Only) Server scalling Battery life · · ·
  13. XMPP

  14. XMPP

  15. XMPP

  16. XMPP Pros Cons Group Chat! Openfire - xmpp server asmack

    - xmpp client for android Messages which are time critical Class attendance OK if offline tablets misses them · · · · · · 0 server side code Good for chat like interactions · · Persistent messages Scaling - cocurrent connections Reliability · · ·
  17. GCM Google Cloud Messageing

  18. GCM Google Cloud Messageing

  19. GCM Google Cloud Messageing

  20. GCM Google Cloud Messageing

  21. GCM Google Cloud Messageing

  22. GCM Google Cloud Messageing

  23. GCM Google Cloud Messageing

  24. GCM Google Cloud Messageing Pros Cons Push notifications Messages upto

    4k Collapsing · · · Good for battery life Server side scalling - no polling · · Still readonly while offline Not 100% reliable · ·
  25. Event Souring http://martinfowler.com/eaaDev/EventSourcing.html Capture appliaction state as events As a

    sequence Can be applied in the same order to get the current state Like a Version Control System All parties in the system just speaks events · · · · ·
  26. Event Sourcing Structure of an Event { " u u

    i d " : " 0 0 0 0 0 1 3 a - e 6 b e - 8 1 4 8 - 1 2 c 5 - 0 3 6 0 6 0 2 e c 2 7 8 " , " t i m e s t a m p " : 1 3 6 6 3 8 8 8 1 4 , " e v e n t T y p e " : " P o s t C r e a t e d E v e n t " , " c r e a t e d B y U s e r I d " : 1 , " a u t h T o k e n " : " s o m e a u t h t o k e n " , " d a t a " : { " s o m e A t t r i b u t e " : " s o m e V a l u e " , " a n o t h e r A t t r i b u t e " : " a n o t h e r V a l u e " } , " s c o p e " : [ 1 , 1 2 0 3 , 3 4 5 ] } J S O N
  27. Event Sourcing

  28. Event Sourcing

  29. Event Sourcing

  30. Event Sourcing

  31. Event Sourcing Pros Cons Data agnostic service Each node can

    device what to listen to Scaling · · · Every party needs to talk event Very hard to integrate with non-event based systems · ·
  32. Using CouchDB A NoSQL datastore Distributed - replica copies Schema

    free JSON documents Incremental master-master replication · · · · ·
  33. CouchDB

  34. CouchDB

  35. CouchDB

  36. CouchDB

  37. CouchDB

  38. CouchDB Cons Heavy - for a android device 10s boot

    time :( · ·
  39. TouchDB Light weight CouchDB compatible Uses SQLite Good enough for

    mobile Replicate data with CouchDB · · · · ·
  40. TouchDB

  41. TouchDB

  42. Thank You Selva github.com/selvakn