How does Docker Swarm load balance?

血红的双手。 提交于 2019-12-10 13:32:52

问题


I have a cluster of 10 Swarm nodes started via docker swarm join command

If i want to scale a docker instance to 15 via

docker service create --replicas 15 

how does docker swarm know where to start the container?

is it round-robin or does it take into consideration of compute resource (how much cpu/mem being used)?


回答1:


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. There are 3 strategies currently available to the leader.

  • spread
  • 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. The random strategy uses no computation. 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. The binpack strategy causes Swarm to optimize for the node which is most packed.

Swarm uses spread by default. Keep in mind you can Constraint Containers on specific nodes too.

It's not possible to set strategies in docker version 1.12.1 (Latest release to posting date)



来源:https://stackoverflow.com/questions/39878419/how-does-docker-swarm-load-balance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!