Skip to content

Instantly share code, notes, and snippets.

@giwa
Last active October 2, 2015 13:26
Show Gist options
  • Select an option

  • Save giwa/76e335799b65b204c6df to your computer and use it in GitHub Desktop.

Select an option

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
apt-get install haproxy
# 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
haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)
listen stats :1936
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /
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