Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Service Discovery and Internal load balancing using DNS

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The following brings you the use of DNS service discovery and internal load balancing, hoping to give you some help in practical application. Load balancing involves more things, there are not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.

1. Using DNS for service

According to the internal DNS CVM, the docker engine can provide name resolution for all containers on user-defined bridges (network), overlay network igressoverla (ovelay) and macvlan networks.

There is an NDS parser within each container that forwards the results of the dns query to the docker engine (docker daemon), which acts as a dns server. The docker engine checks whether the dns query belongs to a container or a request to a cluster service, if it is a container

Then the docker engine looks for the ip that matches the container name, or the service looks in its key store and returns the ip or service virtual ip to the requestor.

Service discovery is network-wide, which means that only containers or tasks located on the same network can use embedded DNS capabilities. If the container or service is not on the same network, the docker engine forwards the dns query to the default DNS server for resolution.

two。 Internal load balancing

When the docker swarm cluster creates services, they are automatically assigned a virtual ip that is part of the service network. Returns vip when resolving the service name. Vip traffic is automatically sent to all health tasks of the service through the overlay network (overlay).

Docker is responsible for routing and distributing traffic evenly among healthy services.

Create an overlay network

Docker network create-d overlay mylay

View the vip assigned by swarm when creating the service

Docker service inspect service name | grep Addr

DNS Loop (DNS RR) load balancing is another load balancing option for the service (configured to-- endpoint-mode).

In DNS RR mode, no VIP is created for each service. The Docker DNS server resolves the service name to a single container IP in a circular manner

3.swarm cluster routing network

The principle of routing network: all nodes in the cluster expose tcp/udp ports, receive external request connection traffic, and then redirect the traffic on the ingress overlay network to a healthy service copy through the kernel IPVS load balancer.

The routing network was introduced by docker engine 1.12, which combines ipvs and iptable to create a cluster-wide transport layer L4 load balance. It allows all nodes in the cluster to receive request connections on published ports.

When any cluster node receives traffic from the tcp/upd port service, it distributes the request traffic to the vip igress of the service using the overlay network specified at the time of service creation.

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

4.swarm layer 7 routing (interlock proxy)

Cluster mode routing networks are ideal for transport layer routing. It routes to the service using the published port of the service. Interlock is a new feature that enables service discovery on the application layer (L7).

This layer 7 route extends to the cluster mode routing grid by adding application layer functions, such as checking HTTP headers. Interlocks are used in conjunction with cluster mode routed networks to provide flexible and powerful service delivery.

After reading the above about service discovery and internal load balancing using DNS, if you have anything else you need to know, you can find out what you are interested in in the industry information or find our professional and technical engineers for answers. Technical engineers have more than ten years of experience in the industry.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report