Show HN: Dynamic load balancing with Docker containers – without swarm mode
olicallaghan.com
olicallaghan.com
A couple of points though:
1) You have a race condition in haproxy.js. If an addNode function is interleaved with a removeNode function, you could have the following result:
removeNode reads the file
removeNode replaces the matching line with nothing
addNode appends a line to the file
removeNode writes the string to the file
Now, addNode has returned true, but its given server is removed immediately because removeNode is not atomic.2) in the // Remove Nodes block, why do you only kill the container when `n == rmNodes - 1`. Say you have 2 nodes to remove, this would remove both from the HAProxy config, but only kill the second of the containers, right?