-
Notifications
You must be signed in to change notification settings - Fork 36
Scaling Fireloop
Building apps with FireLoop is nice and easy, but that would be worthless if the platform wouldn't scale into multiple server or even process instances.
The following documentation will explain how to enable FireLoop to work under clustered environments.
- SDK Builder v2.1.0-rc.10+
- LoopBack Component Real-Time v1.0.0-rc.5+
- Socket IO Adapter (Any valid socket.io-adapter like socket.io-adapter-mongo, socket.io-redis, etc)
- PubSub capable database like MongoDB or Redis
Regardless the datasource you select for your API Models, you will need to create a datasource pointing to a MongoDB or Redis database.
If you already selected MongoDB or Redis database for your API Models, you won't need to create a new datasource, users using any other databases like SQL ones, will require to create a new datasource pointing to MongoDB or Redis and install its LoopBack dependency.
$ cd to/project/api
$ npm install --save [loopback-connector-mongodb | loopback-connector-redis]
and configure as any other LoopBack datasource, example:
{
"mongodb": {
"url": "mongodb://user:pass@host:27016/dbname",
"name": "mongodb",
"connector": "mongodb"
}
}
server/datasources.json
In order to enable the clustering mode, we need to set the following configurations:
{
"@mean-expert/loopback-component-realtime": {
"auth": true,
"debug": false,
"driver": {
"name": "socket.io",
"options": {
"adapter": {
"name": "socket.io-adapter-mongo",
"datasource": "mongodb"
}
}
}
}
}
Please note that the adapter.name
should be the adapter you selected and installed prior this process, as well as the adapter.datasource
should be the name of the datasource you created.
After following the configurations above, FireLoop will work either on clustered process or server environments.