简体   繁体   中英

How services are distributed in docker swarm

Can I somehow configure how master node distributes services in docker swarm? I thought, that it should see free resources of worker nodes and distribute it to "freest" node.

Currently I have problem, that service is distributed into one node, which is full (90% RAM) and it starts be laggy, but at the same time second node has few services and it can handle another one.

docker node ls 
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
wdkklpy6065zxckxyuj000ei4 *   docker-master       Ready               Drain               Leader              18.09.6
sk45rol2whdr5eh2jqozy0035     docker-node01       Ready               Active              Reachable           18.09.6
o4zwwbwwcrbwo4tsd00pxkfuc     docker-node02       Ready               Active                                  18.09.6

Now I have 36 (very similar) services, 28 run on docker-node01, 8 on docker-node02. I thought, that ideal state is 16 services on both nodes. Both docker-nodes are same.

  1. How docker swarm knows where to run service? What algorithm does it use?
  2. It is possible to change/update algorithm for selecting node?

According to the swarmkit project README the only available strategy is spread so it schedule tasks on the least loaded modes.

Note that the swarm won't move nodes around to maintain this strategy so if you added the node02 after the node01 was full then the node02 will remain mostly empty. You could drain both nodes then activate them to see if it distributes better the load.

You can find a more detailed description on the schedules algorithm on the project documentation: scheduling-algorithm

For the older swarm manager this attribute was configurable: https://docs.docker.com/swarm/reference/manage/#--strategy--scheduler-placement-strategy

我还找到了https://docs.docker.com/swarm/scheduler/strategy/ ,它解释了很多有关Docker群策略的信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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