Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a scalable Parse LiveQuery Server?

Tags:

Recently, we started developing a chat feature for our app and since we are already using Parse SDK/Server, we decided to go with the Parse LiveQuery...

The thing is, there's no sufficient enough documentation on how to deploy a Parse LiveQuery server, on a separate one! We saw this: http://docs.parseplatform.org/parse-server/guide/#scalability but we didn't really figured out on how to proceed...

So we have a couple of questions:

What do we need to do, in order to create a scalable Parse LiveQuery Server? (preferably on Digital Ocean / Heroku)

How can it communicate, with our original Parse Server, where our MongoDB is stored?

like image 622
Sotiris Kaniras Avatar asked May 23 '17 19:05

Sotiris Kaniras


People also ask

Is parse better than firebase?

Parse vs Firebase Quick comparison Compared to Firebase, Parse is open-source, has multiple hosting options, and no vendor lock-in. On the other hand, Firebase has a more comprehensive set of features and it is supported by Google.

What is Bitnami parse server?

By: Bitnami by VMware Latest Version: 5.2.6-0 on Debian 11. Up-to-date and secure image. Parse is a platform that enables users to add a scalable and powerful backend to launch a full-featured app for iOS, Android, JavaScript, Windows, Unity, and more.


2 Answers

Here is our way to setup scalable Parse LiveQuery server on Heroku Because there is one and only 'web' process on Heroku, it will divide into two Heroku apps: Main and LiveQuery.

A: Main app - All features except for LiveQuery server

Step A1. Setup a Parse app on Heroku

Step A2. Add a Heroku Redis (free plan is enough for testing)

Step A3. Configure Parse app, add redisURL for liveQuery

var api = new ParseServer({
  ...
  liveQuery: {
    classNames: [...],
    redisURL: REDIS_URL_ON_MAIN
  },
  ...
});

B: LiveQuery app - A scalable LiveQuery server for Main app

Step B1. Steup another Parse app on Heroku

Step B2. Configure Parse app, DO NOT set liveQuery

var api = new ParseServer({
  appId: APP_ID_ON_LIVEQUERY,
  masterKey: MASTER_KEY_ON_LIVEQUERY,
  serverURL: SERVER_URL_ON_LIVEQUERY,
  databaseURI: // (Optional) Only warning even if leave it default
});

Step B3. Create LiveQuery server

var app = express();
app.use(PARSE_MOUNT_ON_LIVEQUERY, api);

var httpServer = require('http').createServer(app);
httpServer.listen(PORT_ON_LIVEQUERY, function() {
  /* Create HTTP server successfully */
});

ParseServer.createLiveQueryServer(httpServer, {
  redisURL: REDIS_URL_ON_MAIN // Redis URL from Mani app
});

C: Client side - Swift for example

Step C1. Init Client instance using

Client(server:applicationId:clientKey:)

let client = Client(server: SERVER_URL_ON_LIVEQUERY, 
                    applicationId: APP_ID_ON_LIVEQUERY, 
                    clientKey: nil)

Step C2. Subscribe for LiveQuery

let subscription = client.subscribe(query)
subscription.handle(Event.created, { query, object in
  /* Handle CREATE event */
})

In the end, we can scale web process in LiveQuery app on Heroku ^_^

Welcome any comments on my glist

like image 69
ananfang Avatar answered Sep 22 '22 10:09

ananfang


In you Parse Server B give the databaseUri of your database A: var api = new ParseServer({ databaseURI: 'mongodb://myMogoURL',

like image 35
Julien Kode Avatar answered Sep 22 '22 10:09

Julien Kode