修改 MQTT broker 連線上限
編輯歷史
| 時間 | 作者 | 版本 |
|---|---|---|
| 2017-03-11 04:29 – 04:40 | r1 – r249 | |
顯示 diff- Untitled
+ 修改 MQTT broker 連線上限
- This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!
+ 隨著 MQTT 使用用戶(終端設備或訂閱者)持續增加,終有一天會遇上資料出現漏接的狀況,這邊分享一下如何修改系統設定,提升MQTT broker 的連線數上限:
+
+ 平台資訊
+ *AWS AMI Linux
+ *Mosquitto 1.4.10
+ *測試日期:2017/3/11
+
+ 修改步驟
+ *修改 /etc/mosquitto/mosquitto.conf
+ *加入這一行,將上限改為無限大(但仍受限於系統整體上限):
+ *max_connections -1
+ *修改 /etc/sysctl.conf
+ *加入這幾行
+ *fs.file-max = 10000000
+ *fs.nr_open = 10000000
+ *net.ipv4.tcp_mem = 786432 1697152 1945728
+ *net.ipv4.tcp_rmem = 4096 4096 16777216
+ *net.ipv4.tcp_wmem = 4096 4096 16777216
+ *net.ipv4.ip_local_port_range = 1000 65535
+ *修改 /etc/security/limits.conf
+ *加入這幾行
+ ** soft nofile 10000000
+ ** hard nofile 10000000
+ *root soft nofile 10000000
+ *root hard nofile 10000000
+ *將系統重新該機即可
+
+ 溫馨提醒
+ 系統重新開機後,請記得確認兩件事:
+ *MQTT broker 是否有跑起來
+ *下遊的 MQTT subscribe 是否有繼續成功連線(可能需要重新啟動)
+
+ 參考資料
+ *Mosquitto increasing maximum connection limit
+ *Mosquitto.conf
|
||
| 2017-03-11 04:29 | r0 | |
顯示 diff+ Untitled
+ This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!
|
||