Microservices in practice Microservices in practice docker docker

Microservices in practice


If you're looking at using a Docker Swarm you don't need to worry about the DNS configurations as it's already handled by the overlay network. Let's say you have three services:

ABC

A is your DB, B might be the first service to collect data, and C to recieve that data and update the database (A)

docker network create \  --driver overlay \  --subnet 10.9.9.0/24 \  youroverlaynetworkdocker service create --network youroverlaynetwork --name Adocker service create --network youroverlaynetwork --name Bdocker service create --network youroverlaynetwork --name C

Once all the services are created they can refer to each other directly by name

These requests are load balanced against all replicas of the container on that overlay network. So A can always get an IP for B by referencing "http://b" or just by calling hostname B.

When you're dealing with load balancing in Docker, a swarm service is already load balanced internally. Once you've defined a service to listen on port 8018, all swarm hosts, will listen on port 8018 and mesh route that to a container in round robin fashion.

It is still, however, best practice to have an application load balancer sit in front of the hosts in the event of host failure.