In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the Docker Swarm service discovery and load balancing principle analysis, I hope you will learn something after reading this article, let's discuss it together!
The technology used
Docker uses the functions of linux kernel iptables and ipvs to achieve service discovery and load balancing.
Iptables is a packet filtering technology available in the linux kernel, which can be used to classify, modify, and forward decisions based on the content of packets.
Ipvs is a transport-level load balancer available in the linux kernel.
Preparatory work
Swarm cluster: [manager] node1, [worker] node2
Client image: registry.cn-hangzhou.aliyuncs.com/anoy/ubuntu
Server image: registry.cn-hangzhou.aliyuncs.com/anoy/vote
As shown in the figure, we will deploy the "client" service and the "vote" service in the swarm cluster, where the "vote" service deploys multiple copies. When the client requests the "vote" service, the output includes the server's container id, which makes it easier to demonstrate the network request.
Cluster status
Docker service create-- name vote-- network overlay1-- replicas 2-p 8080 registry.cn-hangzhou.aliyuncs.com/anoy/vote
The following figure shows the mapping between sandbox, container, and the network of each node:
As shown in the figure, the sandbox and vote containers are part of the "ingress" network, which helps with routing grids. The client container and the vote container are part of the "overlay1" network and help with internal load balancing. All containers are part of the default "docker_gwbridge" network.
Following the nat rules in iptables, host traffic on port 8080 is sent to sandbox in node1:
1 2 3 4 5 5 6 7 8 9 10 11 [root@node2 ~] # curl node1:8080 | grep-I "container id"% total% received% xferd average speed time time time current dload upload total spent left speed100 3162 3162 00 7531 0-7546 processed by container id 6173afd5fab8 [root@node2 ~] # curl node1:8080 | grep-I "container id"% total% received% xferd average speed time time time current Dload upload total spent left speed100 3162 3162 00 169k 0-171k processed by container id b07e95c5c681 finished reading this article I believe you have some understanding of "Swarm Service Discovery and load balancing principle Analysis in Docker". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Original link: https://www.jianshu.com/p/dba9342071d8
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.