Florent Vilmart
florent@flovilmart.com
Parse, Scale to Millions
$ whoami
Dad
Cooking
Beers / Gin / Scotch
Tech Lead
BDFL
Principal Maintainer
•
•
•
•
•
• https://github.com/parse-community
DF*K is Parse?
DF*K is Parse?
•
•
•
•
•
•
DF*K is Parse?
import Parse from ‘parse’
const talk = new Parse.Object(‘Talk’)
await talk.set({
presenter: ‘@flovilmart’,
title: ‘Parse, Scale to Millions’
}).save()
DF*K is Parse?
in JS?
$ npm install -g mongodb-runner # not required
$ sh <(curl -fsSL http://get.parseplatform.org) # bootstrap script
$ mongodb-runner —start && npm start # start the server
Prototyping with Parse
$ npm init && npm install —save parse-dashboard
$ vi config.json
$ vi package.json
$ npm start
Setting up the dashboard
Demo Time!
•
•
(っ˘▽˘)っ ☁️ ⊂(◕。◕⊂)
🚀: checklist
(っ˘▽˘)っ ☁️ ⊂(◕。◕⊂)
# server/app.yaml
runtime: nodejs
vm: true
service: default # for the sake of the demo
resources:
cpu: 1
memory_gb: 0.5
automatic_scaling:
min_num_instances: 1
max_concurrent_requests: 40 # max 80
(っ˘▽˘)っ ☁️ ⊂(◕。◕⊂)
🚀 parse-server: App Engine
# dashboard/app.yaml
runtime: nodejs
vm: true
service: parse-dashboard-demo
manual_scaling:
instances: 1 # just need 1 instance
(っ˘▽˘)っ ☁️ ⊂(◕。◕⊂)
🚀 parse-dashboard: App Engine
(っ˘▽˘)っ ☁️ ⊂(◕。◕⊂)
Under the curtain
Life of req
auth
HTTP
req + body
parsing
Cloud Code
Functions + Jobs
Files
Controller
Files
Adapter
Objects
API
Push Controller
Push
Queue
Database Controller
Push
API
Files
API
Cloud
API
Database
Adapter
Under the curtain
Objects API
Database
Controller
RestWrite RestQuery
Database
Adapter
Cloud Code Hooks + Live QueryAuth Adapters
Cache
Ctrl.
Cache
Adapter
•
•
•
•
Scaling Objects API
it’s all about the DB
{ '$or':
[ { global: '<val>', _rperm: {"$in":["<vals>"]} },
{ location: {"$box":[["<val>"]]}}, _rperm: {"$in":["<vals>"]} } ] }
Scaling Object API
When things go south…
•
•
•
•
•
•
Scaling Caches
LRU Cache
•
•
•
•
•
•
Scaling Caches
The Sweet Spot
•
•
•
•
•
•
•
Scaling Files API
ups and downs
…
filesAdapter: {
module: 'parse-server-gcs-adapter',
options: {
directAccess: true,
bucket: ‘my-bucket’
}
},
…
Scaling Files API
example configuration
•
•
•
•
•
Scaling Push Notifications
it has never been that easy
•
•
•
•
Scaling Push Notifications
Basics
Scaling Push Notifications
spread the load!
Push Controller
Push
Queue Push
Worker
Push
Worker
Push
Worker
Push
Adapter
|
|
|
Push
Adapter
Push
Adapter
|
|
|
Message Queue
Push
Work Item
Push
Work Item
Push
Work Item
Push
Work Item
•
•
•
•
Scaling Push Notifications
leveraging the cluster!
Parse-Server
Parse-Server
Parse-Server
Parse-Server
LB
Message
Queue
(SQS, PubSub.
Kafka…)
Push Queue
Push Worker
Push Queue
Push Worker
Push Queue
Push Worker
Push Queue
Push Worker
Push
Work
Item
Push
Work
Item
Push
Work
Item
Push
Work
Item
Push
Work
Item
Push
Work
Item
Scaling Push Notifications
fan out! Serverless
Parse-Server
Parse-Server
Parse-Server
LB
Push Queue
Push Queue
Push Queue
Push Worker
|
|
|
Push Worker
Push Worker
|
|
|
|
|
|
Message
Queue
(SQS, PubSub,
Kafka…)
Push
Work
Item
Push
Work
Item
Push
Work
Item
Push
Work
Item
Push
Work
Item
Push
Work
Item
•
•
•
•
•
Scaling Live Query
basics
Scaling Live Query
Lifecycle of LiveQueries
Parse Server
Publisher
Live Query Server
Subscriber
Live Query
WebSocket Server Client
Event
Event
Subscribe
SubscribeObject
Created
Object
Created
new Parse.Object(«MyObject«)
.save()
Scaling Live Query
WebSockets don’t scale
Scaling Live Query
WebSockets don’t scale
Live Query Server
Subscriber
Client
Live Query Server
Subscriber
Client
Event
Subscribe
Client
Client
Parse Server
Publisher Object
Created
Parse Server
Publisher
PubSub
(Redis,
GCPS…)
Recommendations

Parse, scale to millions