docker service discovery and load balancing

1. Use DNS for service issued

docker engine according internal DNS server, the bridge may be user-defined (Network), an overlay network igressoverla (ovelay), macvlan network provides all the containers on the host name resolution.

NDS within each container has a parser, dns query results will be forwarded to the docker engine (docker daemon), the engine acts as a dns server. docker engine checks dns queries are part of a container or belong to a cluster service request, and if the container

The docker engine looks for the container that matches the name ip, ip or service or service and to find key-value store in its virtual ip returned to the requestor.

Service discovery is a network-wide, which means that only the container or task on the same network in order to use the embedded DNS functionality. If the container is not in the same network or service, the docker engine dns queries will be forwarded to the default DNS server to resolve.

2. Internal Load Balancing

When you create a service docker swarm cluster, they will automatically assign a virtual ip, which is part of the virtual IP service network. Vip returned when resolving service name. Vip automatically send traffic through the overlay network (overlay) to the service of all health tasks.

docker responsible for routing and flow evenly in the health service.

Creating overlay network

docker network create  -d overlay  mylay

When you create a distribution service to view swarm vip

docker service inspect the service name | grep Addr

DNS round robin (DNS RR) is another service load balancing load balancing option (configured --endpoint-mode).

In DNS RR mode, VIP is not created for each service. Docker DNS server round-robin fashion service name resolves to a single IP container

3.swarm cluster routing network


Principle route network: all nodes in the cluster announced tcp / udp port, the connection request is received from the outside traffic, followed by the kernel's IPVS load balancer cover the ingress traffic on the network is redirected to a copy of the health service.

Routing network is introduced by the docker engine 1.12, the combination of which creates iptable ipvs and transport layer L4 load balancing in a cluster range. It allows all nodes in the cluster receives requests on port connection release.

When any cluster node receives a tcp upd port service flow /, it will use the service to create the specified overlay network traffic requests are distributed to vip igress services.

After starting the service, you can create an external DNS record (announced port --public 80:80) for the application, and mapped to any or all of Docker swarm nodes.

4.swarm Routing Layer 7 (interlocked agent)

Cluster mode routing network layer routing is very suitable for transmission. It uses the services published ports routed to the service. Interlock is a new feature that enables service discovery at the application layer (L7).

This layer 7 routing extension to cluster routing grid pattern by adding an application layer function (e.g. check the HTTP header). Used with interlocking patterns and cluster routing network, to provide flexible and powerful service delivery.


Guess you like

Origin blog.51cto.com/12182612/2428465