How is the load balance of Docker Swarm balanced?

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

If I want to scale the docker instance to 15 in

 docker service create --replicas 15 

how docker swarm knows where to start the container?

Is it cyclic or does it take into account a computing resource (how much cpu / mem is used)?

+5
source share
1 answer

When you create a service or scale it in Swarm mode, scheduler on Elected Leader (one of the managers) will select node to start the service. There are currently 3 strategies available for leaders.

  • spread
  • binpack
  • random

The spread and binpack compute the rank according to the available CPU node, its RAM, and the number of containers that it has. The random strategy does not use calculations. It selects node in random order and is mainly intended for debugging.

According to the spread strategy, Swarm is optimized for the node with the least number of containers. The binpack strategy forces Swarm to optimize for the node that is most packed.

Swarm uses by default. Keep in mind that you can Constraint Containers and on certain nodes.

Unable to set strategies in docker version 1.12.1 (latest version to publish date)

+1
source

Source: https://habr.com/ru/post/1011995/


All Articles