-
-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Review MQTT gem
Review the current MQTT library in use
Shared Subscription
Consider implementing multiple subscriber mqtt_subscriber.rake tasks as it was originally planned to balance ingestion load across multiple rails tasks taking advantage of the Emqx Shared Subscriptions feature.
That could be achieved by adding support to pass a configuration variable to mqtt_subscriber.rake to instantiate multiple tasks via docker-compose.yml
👓 We need to learn more about rake thread / process management. Read here. Otherwise, we might also consider doing it at a docker level. Is it a crazy idea?
Broker SSL/TLS with Let's Encrypt
Review implementation of Let's Encrypt on the MQTT Broker server to confirm renewal and configuration is ok. Currently works well.
MQTT Message persistance
That option is critical to ensure in case rails fails to ingest messages temporary the broker persist the messages for later ingestion. That combined with the new flash based local storage on the SCK 2.1 (after SAM firmware release 0.9.8) ensures in case the broker becomes unavailable data will be persisted by the SCK 2.1 and in case the rails subscription tasks fails data will be persisted at the broker.
Message persistence doesn't require any changes on the broker and is defined by the pub / sub clients. Here an example using mosquitto as a client and our broker in production, EMQ X.
$ mosquitto_pub --host mqtt.smartcitizen.me --topic 'foo/bar' -p 80 -u foo -m 'foo' -q 1
$ mosquitto_sub --host mqtt.smartcitizen.me --topic 'foo/+' -p 80 -u foo -q 1 -q 1 -i bar --disable-clean-sessionIn principle the current MQTT library supports that feature and can be implemented as follows:
| MQTT::Client.connect(host: host, clean_session: true) do |client| |
However, it was implemented previously and lead to some instabilities in production after a mqtt_subscriber.rake crash.
Implementation needs to be reviewed on staging in particular to take in to account the mqtt_subscriber.rake peak load that can occur after a downtime when the broker buffered a lot of data.