Last active
October 2, 2015 13:26
-
-
Save giwa/76e335799b65b204c6df to your computer and use it in GitHub Desktop.
Load balancing using HAProxy for MQTT broker ref: http://qiita.com/giwa/items/5da37c3aca0aee75a628
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apt-get install haproxy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Listen to all MQTT requests (port 1883) | |
| listen mqtt | |
| # MQTT binding to port 1883 | |
| bind *:1883 | |
| # communication mode (MQTT works on top of TCP) | |
| mode tcp | |
| option tcplog | |
| # balance mode (to choose which MQTT server to use) | |
| balance leastconn | |
| # MQTT broker 1 | |
| server broker_1 10.255.4.101:1883 check | |
| # MQTT broker 2 | |
| server broker_2 10.255.4.102:1883 check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| listen stats :1936 | |
| mode http | |
| stats enable | |
| stats hide-version | |
| stats realm Haproxy\ Statistics | |
| stats uri / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stats realm Strictly\ Private | |
| stats auth A_Username:YourPassword | |
| stats auth Another_User:passwd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment