Microservices Setup [beta]
This feature is currently in the beta stage and can change without prior notice.
The feature will be released for General Availability on the Enterprise Edition v4.0.
New in version 3.8.

Pre-requisites

The following environment variables should be set for Rocket.Chat services as well:
Variable
Value
Description
TRANSPORTER
nats://nats:4222
NATS address
DISABLE_DB_WATCH
true
Disables internal DB watcher and rely on mongodb-stream-hub
DISABLE_PRESENCE_MONITOR
true
Disables presence monitoring and rely on the presence-service
INTERNAL_SERVICES_ONLY
true
Do not run external services on rocket.chat process

Micro Services

Rocket.Chat microservices are composed of a few Docker containers:

Accounts

Responsible for user authentications
1
docker run \
2
--name accounts-service \
3
-e MONGO_URL=mongodb://mongo/rocketchat?replicaSet=rs01 \
4
-e TRANSPORTER=nats://nats:4222 \
5
rocketchat/account-service:latest
Copied!

Authorization

Responsible for the validation of access to features
1
docker run \
2
--name authorization-service \
3
-e MONGO_URL=mongodb://mongo/rocketchat?replicaSet=rs01 \
4
-e TRANSPORTER=nats://nats:4222 \
5
rocketchat/authorization-service:latest
Copied!

DDP Streamer

Web socket interface between server and clients
1
docker run \
2
--name ddp-streamer \
3
-e MONGO_URL=mongodb://mongo/rocketchat?replicaSet=rs01 \
4
-e TRANSPORTER=nats://nats:4222 \
5
rocketchat/ddp-streamer-service:latest
Copied!
DDP Streamer should be scaled from the beginning. (One per 500 concurrent users should be good enough)

MongoDB Stream Hub

Can not be scaled to multiple containers
Receives real-time data from MongoDB and emits that data to the system.
1
docker run \
2
--name mongodb-stream-hub \
3
-e MONGO_URL=mongodb://mongo/rocketchat?replicaSet=rs01 \
4
-e TRANSPORTER=nats://nats:4222 \
5
rocketchat/stream-hub-service:latest
Copied!

Presence (Optional)

Controls and update users' presence status.
In a situation where you have a huge amount of data/users, you can get away with not running it to reduce the traffic of presence processing. If you are not running it, the user's online/offline status and notification will not work properly.
1
docker run \
2
--name presence-service \
3
-e MONGO_URL=mongodb://mongo/rocketchat?replicaSet=rs01 \
4
-e TRANSPORTER=nats://nats:4222 \
5
rocketchat/presence-service:latest
Copied!

Environment variables common to all services

Set the following environment variables to enable Prometheus metrics:
Variable
Default
Description
MS_METRICS
false
Enable Prometheus metrics endpoint
MS_METRICS_PORT
9458
Port of Prometheus metrics endpoint

Reverse proxy

Once all services are up and running the web socket connections should be targeted to ddp-streamer containers, the configuration depends on the reverse proxy you have set up, but you need to change the following routes:
    /sockjs
    /websocket
If using Kubernetes, an Ingress like the following can be used:
1
apiVersion: extensions/v1beta1
2
kind: Ingress
3
metadata:
4
name: ddp-streamer
5
spec:
6
rules:
7
- host: your-hostname.rocket.chat
8
http:
9
paths:
10
- backend:
11
serviceName: ddp-streamer
12
servicePort: 3000
13
path: /(sockjs|websocket)
Copied!

Summary:

To summarize it:
    1.
    You just need to deploy the reverse proxy to split the communication.
    2.
    Run all the above services pointing to the NATS and the MongoDB.
    3.
    Deploy NATS.
    4.
    Run Rocket.Chat according to the above-mentioned variables.
Last modified 20d ago