8266:

Arduino IDE client for MQTT on 8266

Mosquitto:

getting started tutorial another getting started tutorial documentation mosquitto test server mosquitto has a limit of the number of open connections as defined by ulimit -n. It defaults to 1024 but can be increased e.g. sudo ulimit -n 2048

explore limits as in this thread

mosquitto client:

example pub call: mosquitto_pub -h filimin.no-ip.info -p 8883 -d -t hello/world -m “Hello World” –insecure –cafile /tmp/ca.crt -I ESP8266

cleansession and the retain flag

erase all retained messages: mosquitto_sub -i <client_id> -p <port> -h <host> –retained-only -t “#” -v | while read line; do let “x=x+1”; echo $x; mosquitto_pub -i <client_id> -p <port> -h <host> -t “${line% *}” -r -n; done'

HA Proxy:

Configuring for high # of connections (tested on 16.04)

edit /etc/sysctl.conf and add the following lines (increase open file limit and decrease memory use of TCP buffers:

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 = 15000 65535

edit /etc/security/limits.conf:

* soft nofile 10000000
* hard nofile 10000000
root soft nofile 10000000
root hard nofile 10000000

add to /etc/haproxy/haproxy.conf: in defaults:

maxconn 2000000
timeout connect 3000000 # necessary?
timeout client 66000000 # necessary?
timeout server 66000000 # necessary?

 

check:

pidof haproxy
cat /proc/630/limits | grep 'open files'

increase ip_local_port_range

References

Lelylan is an IoT framwork to making clustering etc. easier

chart comparing MQTT brokers

complete article showing clustering with Mosca, HA Proxy and friends