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

Firebase, Firestore Find mBaaS

nnao45
April 17, 2019

Firebase, Firestore Find mBaaS

nnao45

April 17, 2019
Tweet

More Decks by nnao45

Other Decks in Technology

Transcript

  1. C N D J P 2 @nnao45 CyberAgent Inc. Infra/ServerSide

    Engineer ✔ Naoya Yokoyama Tech Advisor Startup Company ✔ Zsh,BGP,Go,Rust,MySQL,K8S,AWS,Ansible ✔ Vtuber,Game,Tennis ✔ サーバレスでエンジニアに愛を・・・! 冪等性を保つべきかどうかの指標が欲しい ぶいちゅーばー友達募集! ポケモン発売まで意識飛ばしたい勢 Rustのwebフレームワーク作成中... @nnao45,[email protected] ✔ サンフランシスコのセブン最高
  2. DEPLOY MOBILE APP IS HARD WAY Database? Mongo,MySQL,Postgres,Oracle...etc Auth? Basic,Digest,JWT,PubKey...etc

    Async Logic? WebRTC,Quic,CustomProto…etc Hosting API? S3 Hosting,EC2,GAE…etc
  3. DEPLOY MOBILE APP IS HARD WAY Database! Auth! Async Logic!

    Hosting API! NoSQL Authentication SDK and WebRTC Hosting Front
  4. CAN DEPLOY MOBILE APP USING ONLY FIREBASE WITH SERVERLESS ARCH

    hoge.firebaseapp.com Hosting NoSQL Authentication Cloudfunction Storage Push Notification Front
  5. FOR EXAMPLE… MOBILE APP SEND MESSAGE Hosting api.hogame.link/api/v1/login Credential OK

    Credential Auth Authentication Call Privider host with like app
  6. FOR EXAMPLE… MOBILE APP SEND MESSAGE Hosting api.hogame.link/api/v1/message POST Message

    OK Firestore Cloudfunction SAVE Message Format Message SAVE for Analy Object Storage Storage SAVE Image DWH Analytics Tools
  7. FOR EXAMPLE… MOBILE APP SEND MESSAGE Hosting Firebase Apple Push

    iOS Push Message Notification Service Push Message Cloud Messaging api.hogame.link If you want to send push...
  8. FOR EXAMPLE… MOBILE APP SEND MESSAGE Hosting api.hogame.link/api/v1/message GET Message

    Firestore GET Message Storage GET Image Realtime Via SDK on WebRTC
  9. Firestore is NoSQL users/ user_1/ user_2/ user_3/ created: 1555302970 role:

    admin status: active created: 1555302960 role: admin status: active created: 1555302931 role: admin status: deactive
  10. Firestore is NoSQL users/ user_1/ user_2/ user_3/ role: admin status:

    active role: admin status: active role: admin status: deactive follows: [2,3] follows: [4,10] follows: [42,3] docData .put(“follows”, Arrays.asList(2,3)); created: 1555302970 created: 1555302960 created: 1555302931 Insert into data
  11. Firestore is NoSQL users/ user_1/ role: admin status: active follows:

    [2,3] Message.put(“from”, “Jobana”); Messages created: 1555302970 messages/ message_1: from: Giorno msg: Golden Message.put(“msg”, “Experience”); .put(“message_2”, Message); message_2: from: Jobana msg: Experience Insert into subcol
  12. Firestore is NoSQL users/ user_1/ user_2/ role: admin status: active

    role: admin status: active follows: [2,3] follows: [4,10] docDataRef .where(“status”, “==”, “active”); created: 1555302970 created: 1555302960 Get match data
  13. Firestore is NoSQL users/ user_1/ role: admin status: active follows:

    [2,3] docDataRef .where(“crated”, “>”, “1555302965”); created: 1555302970 Get match data
  14. Firestore is NoSQL users/ user_1/ user_2/ user_3/ role: admin status:

    active role: admin status: active role: admin status: deactive follows: [2,3] follows: [4,10] follows: [42,3] docDataRef .where(“role”, “==”, “admin”) created: 1555302970 created: 1555302960 created: 1555302931 .orderBy(“created”, “asc”); Get match sort data
  15. Firestore is NoSQL users/ user_1/ user_2/ role: admin status: active

    role: admin status: active follows: [2,3] follows: [4,10] docDataRef .where(“role”, “==”, “admin”) created: 1555302970 created: 1555302960 .orderBy(“created”, “asc”) .startAt(user_2); Get match sort snap
  16. Caution of Firestore 1 WRITE IN 1 DOCMENT PER 1

    second https://firebase.google.com/docs/firestore/quotas?hl=ja 500 WRITE IN 1 COLLECTION PER 1 second 1 DOCUMENT MAX SIZE IS 1 MiB
  17. 1 DATA UPDATE IN 1 DOCMENT PER 1 second like_counter/

    counter: 222 CANNOT USING“COUNT” STATEMENT https://firebase.google.com/docs/firestore/solutions/counters?hl=ja Caution of Firestore
  18. 1 DATA UPDATE IN 1 DOCMENT PER 1 second like_counter_1/

    counter: 22 → SOLVE: Distributed Sharding like_counter_2/ counter: 34 like_counter_3/ counter: 22 like_counter_4/ counter: 19 97 like_counter: https://firebase.google.com/docs/firestore/solutions/counters?hl=ja Caution of Firestore
  19. BILLING PER Document Bill Read 0.1 Million Doc Write 0.1

    Million Doc Delete 0.1 Million Doc $0.06 $0.18 $0.02 https://firebase.google.com/docs/firestore/pricing?hl=ja Caution of Firestore
  20. Collection BILLING PER 1 Document Document Document Document READ 100

    documents READ 100 documents Your Bill is Caution of Firestore
  21. Collection BILLING PER 1 Document Document Document Document READ 100

    documents SubCollection Document Document Document AND 55 subdocuments Caution of Firestore
  22. Collection BILLING PER 1 Document Document Document Document READ 100

    documents SubCollection Document Document Document AND 55 subdocuments READ 155 documents Your Bill is Caution of Firestore
  23. PUSH NORTIFICATION IS HARD WAY API Firebase Push Message Cloud

    Messaging REQUEST REQUEST HTTP REQUEST IS SLOW RESPOMSE IS SLOW
  24. PUSH NORTIFICATION IS HARD WAY API Firebase Push Message Cloud

    Messaging REQUEST REQUEST I'am New User
  25. PUSH NORTIFICATION IS HARD WAY API Firebase Push Message Cloud

    Messaging REQUEST REQUEST I'am Influencer
  26. API Firebase Cloud Messaging REQUEST REQUEST PUSH NORTIFICATION IS HARD

    WAY ...PREDICTION IS HARD REQUEST Apple Push Notification Service
  27. PUSH NORTIFICATION IS HARD WAY Database /a-service /b-service API a-queue-0/

    Format Data b-queue-0/ Format Data a-queue-1/ Format Data
  28. PUSH NORTIFICATION IS HARD WAY BATCH BATCH BATCH BATCH Push

    Server x-queue-n: datas/ <struct> a-queue-0 a-queue-1 b-queue-0 b-queue-1 statefulset statefulset statefulset statefulset Database
  29. PUSH NORTIFICATION IS HARD WAY IF ALL QUEUE TOO BUSY...

    a-queue-0 a-queue-1 a-queue-2 a-queue-3 a-queue-4 DEPLOY DEPLOY DEPLOY statefulset statefulset statefulset statefulset statefulset API KICK JOB REQUEST Database