The connection limit specifications SHOULD be the same for all members of a cluster but this is just to make management and log correlation easier. There is no check for the limits being the same or not. The logic used to allow or deny connections should not fail if the cluster members are configured with different limits.
In practice a connection to a node is allowed or denied based on the current number of connections known by this node. The number of current connections includes the local connections made directly to this node and the shadowed connections made to other cluster members.
- If a connection is denied due to configured connection limits then none of the other cluster members sees the connection. The connection and its denial are all handled on the local node.
*If the connection is allowed then the connection is shadowed to the other cluster members who count the connection against their configured limits. Shadowed and local connections count against all three connection limits: --max-connections, --max-connections-per-user, and max-connections-per-ip. Shadowed connections that cause a node to exceed a configured connection limit only emit a warning log message and allow the connection to persist.
Connections are shadowed among cluster members. If node A has three local connections and node B has three local connections then each node has six connections in total. Configured connection limits are applied to new connections being created on the local node. If nodes A and B have different limits then each node will use a different limit when allowing connections to itself.
The code in its current state also allows clusters to create more connections than specified on the command line. For instance suppose you have a three node cluster, --max-connections-per-user=4, and user bob is connected three times. Next suppose each cluster member simultaneously receives a new connection from bob. Each cluster member will see three connections from bob and allow the connection. Each shadowed connection propagates to cluster peers and is observed but not denied and bob may now have 6 connections. The rule is that a cluster of M member nodes that specify N connections may have up to (N + M-1) connections.