-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Review MQTT implementation for scalability #198
Comments
Also the current gem was last updated in 2016 |
Asesing the migration from Event Machine (and ruby-em-mqtt)
The following conclusion leads to three potential solutions to evaluate:
🔍 The research continues... |
Adding to the MQTT EMQX. We currently have migrated EMQX to 5.0.1 on staging and is running correctly with the following settings (ports and domain are redacted):
The broker itself does need changes on the deployment, as seen above. The connection of the rails tasks with the
SSL is working fine at least on the dashboard, although there were some (now-solved) issues with regards to user permissions of the cert files in the docker volume. In principle, it should all go well on WSS and SSL listeners. Issue is solved by (check here and here):
TODO |
Comments on the renewal:
|
Documented in docs/mqtt.md in the #293. Comments above are not up to date. |
One good place to take a look at and see how we are handling the mqtt messages is on the Slow subscription view of the EMQX broker: https://mqtt.smartcitizen.me:18084/#/slow-sub This basically will queue up and buffer on mqtt the excess of unreceived messages. Notifications can be enabled via mqtt, so that we can trigger an email or similar. |
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.
In principle the current MQTT library supports that feature and can be implemented as follows:
smartcitizen-api/lib/tasks/mqtt_subscriber.rake
Line 13 in 3e9202b
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.
The text was updated successfully, but these errors were encountered: