FireLoop.io
FireLoop.io

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.

Requirements

Creating DataSource

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.

1
2
$ cd to/project/api
$ npm install --save [loopback-connector-mongodb | loopback-connector-redis]

and configure as any other LoopBack datasource, example:

1
2
3
4
5
6
7
{
"mongodb": {
"url": "mongodb://user:pass@host:27016/dbname",
"name": "mongodb",
"connector": "mongodb"
}
}

server/datasources.json

Enable Clustering Mode

In order to enable the clustering mode, we need to set the following configurations:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"@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.