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

Modeling DB @ Cloud Firestore

Modeling DB @ Cloud Firestore

push ID: auto ID in Realtime Database

Ff5a69761197ae0dffc06ed56203ba98?s=128

Yatima-Kagurazaka

December 16, 2017
Tweet

Transcript

  1. Modeling DB @ Cloud Firestore Yatima Kagurazaka ://yati.ma

  2. yati.ma/qi Yatima Kagurazaka Minkore CTO MENSAn Physician I like tech,

    design, music, etc My PC: Pixelbook(+ VSCode on Kali Linux)
  3. yati.ma/qi Agenda • What is Cloud Firestore • Structure •

    Yatima Model
  4. What is Cloud Firestore

  5. So easy but Equal to prod. use and Inexpensive

  6. yati.ma/qi So easy Realtime Offline mode Direct connect to clients

    (like Realtime Database)
  7. yati.ma/qi Equal to prod. use Almost no downtime Super scalability

    Multi region Strong Consistency Some query support
  8. yati.ma/qi Almost no downtime

  9. “ yati.ma/qi Super scalability you'll get the same performance fetching

    1 result from a set of 100, or 100,000,000.
  10. Structure

  11. Collection, Doc, Field

  12. Collection, Doc, Field

  13. A doc is minimum unit at communication

  14. yati.ma/qi A doc is minimum unit Read Write Rule Update

    limit: 1/sec Subcollection depth: ≦ 100
  15. All queries are shallow

  16. Query is available only in a collection, so far

  17. For making full use, change a way of thinking

  18. Yatima Model

  19. UniFeed: Supereasy timeline system

  20. None
  21. yati.ma/qi UniFeed: Usage Just query at viewer self ID!

  22. yati.ma/qi UniFeed: Limit Indexes in a document: ≦ 20,000 But

    we can batch() (≦ 500)
  23. yati.ma/qi Multi UniFeed Follower: ≦ 10,000,000 (20,000 * 500) ...Actually,

    not everyone follow one Probably up to approx. 1M follower in rough estimate
  24. yati.ma/qi Level 2 multi UniFeed Add batch() at Cloud Functions,

    more scalable Follower: ≦ 5,000,000,000 (20,000 * 500 * 500) and you can go any level! your bank balance vs Google’s capacity
  25. Twixxer should use it immediately :-P

  26. But wait, how about doc size?

  27. yati.ma/qi UniFeed: Doc size w/ auth.uid: < approx. 600kb (20,000

    * 30 chars) w/ pushid: < approx. 300kb (20,000 * 15 chars) ...Actually, not everyone bla bla so at most 30kb, usually 300 or less (realistic!)
  28. Firebase as a Cache (Componentized DB, Virtual DB)

  29. yati.ma/qi General: Write

  30. yati.ma/qi General: Read

  31. yati.ma/qi FaaC: Write Virtual DB

  32. yati.ma/qi FaaC: Read

  33. yati.ma/qi FaaC: Pros Componentized DB Flux-like data flow Explicit communications

    Flexibility of DB Faster view
  34. yati.ma/qi Flux architecture

  35. yati.ma/qi General: Data flow

  36. yati.ma/qi FaaC: Flux-like data flow Virtual DB

  37. yati.ma/qi General: Implicit comm. Who are you?

  38. yati.ma/qi FaaC: Explicit comm. I know! Same component

  39. yati.ma/qi FaaC: Cons Need to edit DB/rule occasionally (Build tool

    overcome it) Fetch per component
  40. yati.ma/qi FaaC: Background Lower cost to edit DB Component-Based Architecture

    Denormalize Trend of static contents CDN
  41. A doc is minimum unit! English is difficult for me!

  42. Fin. ヾ(╹◡╹*)ノ゛ Throw your masakari axe at me! ://yati.ma