Haproxy only connecting to one backend server

graphitehaproxytcp

I am having some trouble with what should be a very basic configuration on an Ubuntu 16.04 server to use haproxy to load balance incoming metrics across two carbon-relay processes. Haproxy is only creating a TCP connection to the first server in the list of servers in the "listen" section. Also, when I tcpdump and watch for both carbon-relay ports, only the one connected receives any metrics from haproxy, but if I enable the "check" parameter in the server entries, the health checks do show up in the tcpdump output.

If I comment out the first server, or reverse their order, it does connect to the other server, and other testing doesn't indicate any problems with the carbon-relay processes, so I'm stumped as to why it will only connect to one server.

I have tried roundrobin, static-rr, and leastconn for the balance option, as well.

Here's a gist with the relevant sections of haproxy.cfg and carbon-relay.conf, plus the netstat output to show the listening ports and tcp connection to the one server.

https://gist.github.com/Calygos/b1442e0936adafb27fc80a76477235e9

Best Answer

Given that you only have a single client (local collectd process), HAProxy is working exactly as it should.

It's receiving the connection from collectd, and picking one of the two backend servers. If you had more clients, then it would start to balance the traffic to both.

If you wanted to test this, set your balance algorithm to roundrobin and restart collectd. Yuu should see this new connection hit the other backend server.

Alternatively, you could start a second connection (with collectd, or even telnet) and it should find it's way to the second server.