简体   繁体   English

Docker Swarm如何实现负载均衡?

[英]How does Docker Swarm load balance?

I have a cluster of 10 Swarm nodes started via docker swarm join command 我有一个由10个Swarm节点组成的集群,通过docker swarm join命令启动

If i want to scale a docker instance to 15 via 如果我想将docker实例扩展为15

docker service create --replicas 15 

how does docker swarm know where to start the container? docker swarm如何知道启动容器的位置?

is it round-robin or does it take into consideration of compute resource (how much cpu/mem being used)? 它是循环还是考虑到计算资源(使用了多少cpu / mem)?

When you create a service or scale it in the Swarm mode, scheduler on Elected Leader (one of the managers) will choose a node to run the service on. 当您在Swarm模式下创建服务或扩展服务时, Elected Leader上的scheduler (其中一个管理器)将选择一个节点来运行该服务。 There are 3 strategies currently available to the leader. 目前领导者有3种策略可供使用。

  • spread 传播
  • binpack binpack
  • random 随机

The spread and binpack strategies compute rank according to a node's available CPU, its RAM, and the number of containers it has. spreadbinpack策略根据节点的可用CPU,RAM以及它拥有的容器数来计算排名。 The random strategy uses no computation. random策略不使用计算。 It selects a node at random and is primarily intended for debugging. 它随机选择一个节点,主要用于调试。

Under the spread strategy, Swarm optimizes for the node with the least number of containers. spread策略下,Swarm优化容器数量最少的节点。 The binpack strategy causes Swarm to optimize for the node which is most packed. binpack策略使Swarm针对最多打包的节点进行优化。

Swarm uses spread by default. Swarm默认使用spread。 Keep in mind you can Constraint Containers on specific nodes too. 请记住,您也可以在特定节点上Constraint容器。

It's not possible to set strategies in docker version 1.12.1 (Latest release to posting date) 在docker版本1.12.1(最新版本到发布日期)中设置策略是不可能的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM