Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker swarm multiple managers and workers Vs

I have a 3 node docker swarm cluster. We might want to have 2 managers. I know at one time there is only one leader. Since it is a 3 node cluster, I am trying to find some literature to understand what are the pros and cons of multiple managers. I need this info since in my 3 node cluster if I have 2 masters, 1 worker, what is the downside if I simply create 3 masters in a cluster. Any thoughts would be helpful.

like image 385
curiousengineer Avatar asked Jun 13 '17 17:06

curiousengineer


People also ask

What is the difference between a manager and a worker in Docker Swarm?

Manager nodes elect a single leader to conduct orchestration tasks. Worker nodes receive and execute tasks dispatched from manager nodes. By default manager nodes also run services as worker nodes, but you can configure them to run manager tasks exclusively and be manager-only nodes.

Why should there be an odd number of managers in a Docker Swarm?

You should maintain an odd number of managers in the swarm to support manager node failures.

What is the benefit of having more manager nodes present in a swarm?

When you have multiple managers you can recover from the failure of a manager node without downtime. A three-manager swarm tolerates a maximum loss of one manager.

What is the recommended number of manager nodes in Docker Swarm?

Docker recommends a maximum of seven manager nodes for a swarm.


1 Answers

A Docker swarm with two managers is not recommended.

Why?

Docker swarm implements a RAFT consensus:

Raft tolerates up to (N-1)/2 failures and requires a majority or quorum of (N/2)+1 members to agree on values proposed to the cluster. This means that in a cluster of 5 Managers running Raft, if 3 nodes are unavailable, the system will not process any more requests to schedule additional tasks

So with 2 managers, if one is down, the other will not be able to schedule additional tasks (no cluster upgrades, no new services, etc...).

The docs is also clear about the number of managers you should have for high availability :

Size your deployment

To make the cluster tolerant to more failures, add additional replica nodes to your cluster.

Manager nodes Failures tolerated
    1                 0
    3                 1
    5                 2
    7                 3

So in brief, as the doc states here:

Adding more managers does NOT mean increased scalability or higher performance. In general, the opposite is true.

like image 100
François Maturel Avatar answered Oct 16 '22 19:10

François Maturel