4 ms·
> DNS round robin load balancing: It’s now possible to load balance between containers with Docker’s networking. If you give multiple containers the same alias,
by esseti 11y ago
> DNS round robin load balancing: It’s now possible to load balance between containers with Docker’s networking. If you give multiple containers the same alias, Docker’s service discovery will return the addresses of all of the containers for round-robin DNS.
wait wait wait. I'm kind of new into docker world. And so far i've been struggling in understanding how to replicate a container in order to scale.
For example i want to run the same Django project 3 time as web1, web2, web3. If i do so now i've to expose 3 different ports, one for each. Plus, to make it working, I need to have a load balancing, thus i've to use HAProxy and do a load balancing to point to each of the container. Anytime I add a new machine (e.g., web4) i've to change the conf of HAProxy and restart it. This brings down the system for a moment. (is this the right approach btw?)
Going back to the cite paragraph. Now i can create many containers and dockers automatically does the routing for me? Am I right? or I misunderstood the meaning of the cited point?
I just need to create all of them with a --alias web ?
- m_mueller 11y ago> (is this the right approach btw?) This is why I use hipache for load balancing / routing - it is the only solution I've found where you can change the routing or add new backends in a live system without any downtime. Here is the main problem though: Its load balancing isn't exactly smart, for example it won't keep the same client IP on the same replica, thus creating problems when a client writes something on one replica, then gets switched to another that didn't get the update yet. I'd love a better solution for this btw. Is noone working on Hipache anymore? Other than this problem I find it very elegant.
- code_research 11y agoyou might want to take a look at fabio: https://github.com/eBay/fabio https://github.com/eBay/fabio
- doublerebel 11y agoI love Fabio. The Consul stack in general is fantastic. Been watching #consul IRC for a while now though, and the vast majority of the setup problems are due to Docker's weird networking and security. Fabio/Consul run like a charm but Docker throws a wrench in the machine.
- e12e 11y ago> Anytime I add a new machine (e.g., web4) i've to change the conf of HAProxy and restart it. This brings down the system for a moment. (is this the right approach btw?) You might find this story from a year ago interesting: "True Zero Downtime HAProxy Reloads" http://engineeringblog.yelp.com/2015/04/true-zero-downtime-haproxy-reloads.html http://engineeringblog.yelp.com/2015/04/true-zero-downtime-h... HN discussion (with some answers from the post author): https://news.ycombinator.com/item?id=9369051 https://news.ycombinator.com/item?id=9369051 I'm curious as to how much of an actual issue you experience though. Barring an error that prevents HAproxy from starting, it should be pretty quick? Maybe not quick enough for streaming media/realtime audio-visual communication though.
- thresh 11y agoYou can use nginx to have zero-time redeployments without gross hacks haproxy requires to do that.
- falcolas 11y agoI would also recommend nginx. For pure proxying it's rather convenient, and offers some nice high level caching if you desire it.
- esseti 11y agoBut to use nginx i've to recreate the container to link the new "web4" container. don't I? and then to make it reload the conf. or is there anything else that i can do?
- moondev 11y agoWhy load balance three copies of a container on the same server? Just set your cpu and memory constraints to what you need for one.
- esseti 11y agoyou got a point indeed. My idea was to handle more things in parallel for services that are not heavy in resources. such as a service that checks the auth of a user from a ID/Key. anyway, with the swarm I could put the containers in various machines.
- sanimej 11y agoYes, for ex: docker run -d --name web1 --net prod --net-alias web <webapp> docker run -d --name web2 --net prod --net-alias web <webapp> resolution for 'web' will return IPs of both the containers. You might still have to watch out for the DNS caching at the application level.