aedes-cli
aedes-cli copied to clipboard
[question] How to create `aedes` broker cluster in Docker?
First asked on SO.
I need to create a MQTT broker cluster. I want to use aedes
(as I already use it, albeit without cluster) and Docker. Note that I have never created a cluster before (with nor without Docker).
Here I found official example how to create a cluster using aedes
, but I was thinking about using aedes-cli
Docker image.
Now, I have no idea which is better: should I create separate containers per broker (similarly to this question) or use mqemitter-redis
/mqemitter-mongodb
(as the aedes-cli
docs suggest).
As for creating separate containers, I have no idea how to connect them.
As for using mqemitter-redis
/mqemitter-mongodb
, I have no idea how to setup them in the aedes-cli
config file.
I have no need for data persistance accross broker cluster restarts. All I need is to distribute the messages accross multiple brokers in order to improve the runtime performance.
Below is a working, single-broker configuration.
-
aedes.yml
:
version: '3.7'
services:
aedes:
container_name: aedes
image: moscajs/aedes:latest
restart: always
stop_signal: SIGINT
network_mode: host
command: -c /data/dockerConfig.js
volumes:
- /some/path/mqtt:/data
mongo:
container_name: mongo
restart: always
network_mode: host
logging:
driver: none
image: mvertes/alpine-mongo
volumes:
- mongo_data:/data/db
ports:
- 27017:27017
volumes:
mongo_data:
name: mongo_data
-
/some/path/mqtt/dockerConfig.js
module.exports = {
protos: ['tcp', 'ws'],
host: 'localhost',
port: 1883,
wsPort: 3000,
wssPort: 4000,
tlsPort: 8883,
key: null,
cert: null,
rejectUnauthorized: true,
credentials: null,
brokerId: 'aedes',
concurrency: 100,
queueLimit: 42,
maxClientsIdLength: 23,
heartbeatInterval: 60000,
connectTimeout: 30000,
stats: false,
statsInterval: 5000,
mq: {
name: 'mongodb',
options: {
url: 'mongodb://localhost:27017/aedes'
}
},
verbose: false,
veryVerbose: false,
noPretty: false
}