Experiments with load balancing a flask app using nginx or haproxy
todo
From project root, for 3 web-servers:
docker-compose -f compose-haproxy-preconf.yml up --scale hiworld=3
Connect to port localhost:8080 to see the load balancing effect.
Useful for playing with haproxy config file parameters.
docker-compose -f compose-haproxy-custom.yml up # Builds initial containers and creates network
Because the project directory is called src, you'll get containers named like src_redis_1. If you want a
better name, add the argument -p, --project-name to docker-compose:
docker-compose -f compose-haproxy-preconf.yml -p hi-hiproxy up
I find (Docker for Mac 17.03.1-ce, compose 1.11.2) simply re-running docker-compose scale with a lower count
doesn't reduce the count on the next docker-compose up, you must first run docker-compose down, re-scale,
then back up to get the reduction.
Initially, running the bash command below will demonstate round-robin behaviour by the load balancers. The hostname will change as the hit counter increments.
for i in {1..10}; do time curl localhost:8080; done;