Define MongoDB read preferences and read/write concerns - Fluid Topics - 3.8

Install Fluid Topics on Multiple Servers

Operating system
Debian
Category
Technical Notes
Audience
public
Version
3.8

To specify the Mongo Read Preference option:

Add the following lines to the mongo.conf.json file:

As antidot user

{
"hosts": [
...
],
...
"readPreference": {
"mode": "$READ_PREFERENCE_MODE",
"tagSets": [
{
"trendy": [
"true"
],
"backup": [
"false"
]
}
],
"maxStalenessSeconds": 150
}
}

If not specified, the default value for "mode" is "primary". It means that data is read from the MongoDB primary node instance.

To configure the Read Concern:

Add the following lines in the mongo.conf.json file:

As antidot user

{
"hosts": [
...
],
...
"readConcern": {
"level": "local"
}
...
}

To configure the Write Concern:

Add the following lines in the mongo.conf.json file:

As antidot user

{
"hosts": [
...
],
...

"writeConcern" : {
"w" : "majority",
"wtimeout": 50,
"j": false
}
}

The default value for "w" is "1". It means that data is written in the MongoDB primary node instance.

The following diagram shows the default setting for MongoDB Read and Write preferences:

MongoDB read and write default mechanism

As tenant-related content is stored in the MongoDB databases, it is recommended to have several MongoDB instances in case one would crash. It will prevent from any data loss.

For these modifications to be taken into account, it is mandatory to restart the Fluid Topics server by running the following command:

As root user

systemctl restart fluidtopics

To make sure that apache2 is enabled to auto start when the server restarts, run the following commands:

As root user

chkconfig --add apache2
chkconfig apache2 on
systemctl start apache2

If necessary, install the chkconfig utility on your server.