consul icon indicating copy to clipboard operation
consul copied to clipboard

Frequent membership loss for 50-100 node cluster in AWS

Open Amit-PivotalLabs opened this issue 11 years ago • 67 comments

The main problem we're seeing is we have KV data associated with a lock, and hence a session, and the agents associated with those sessions "frequently" lose membership briefly, invalidating the associated KV data. By "frequently", I mean that in a cluster consisting of 3 consul servers and 50-100 other nodes running consul agents, we see individual isolated incidents of agent membership lost every 3-4 hours, roughly (sometimes ~30 mins apart, sometimes 7-8 hours apart, but generally seems to be randomly distributed with an "average" of 3-4).

We have a heterogeneous cluster configured as a LAN, deployed across 3 AZs in EC2. It appears that there is no correlation between the type of node and the loss of membership (e.g. if we have 10 instances of service A, and 50 of service B, we will see roughly 2 membership losses of A instances, and 10 instances of B losses in a period of a few days). It also appears to be independent of stress on the system, i.e. we see roughly the same distribution of membership loss when the system is idle as we do when it's under heavy load.

We use consul for service discovery/DNS as well as a KV store. We use the KV store specifically for the purpose of:

  • maintaining presence -- certain nodes maintain the presence of a key with a TTL on it to indicate they are up and running, and when those disappear another node can react and re-schedule the workload that was being performed by that node, and
  • locks -- for multiple instances of the same service to determine which one actually provides the service, in the case where the service needs to be a singleton

In addition to the occasional member loss, we also have the issue that when we roll the consul server cluster, which triggers a leader election, the KV store is temporarily unavailable. This potentially prevents a presence maintainer from bumping its lock before the TTL expires.

Questions:

  1. Are there ways to configure things so that membership is more robust/more forgiving? We've seen that WAN has more conservative parameters, e.g. a larger SuspicionMult(iplicationFactor), but switching to WAN feels like it would just be papering over an issue, and would only reduce the frequency of this issue.
  2. Is there any advice for a better way to implement "presence maintenance"? Because we use locks, and hence sessions, we're sensitive to the lossiness of UDP and probabilistic nature of Gossip, even though the running application maintaining its presence in the KV stores is running fine. E.g. is there a way to establish a lock but side-step the coupling to the membership of its agent?
  3. What information would help diagnose this problem? We have plenty of server and agent configuration, consul server logs, consul agent logs, and application logs from services running alongside consul agents, all spanning several days.

Thanks, Amit + @matt-royal

Amit-PivotalLabs avatar May 07 '15 17:05 Amit-PivotalLabs

@Amit-PivotalLabs That is certainly strange. Could you attach some log files during one of these losses? It is generally useful to see both sides of the log (e.g. the node that was suspected of failure, and the node that did the suspecting, it should be clear which two nodes are involved via the logs). This may also expose some pattern of pairs.

With respect to the questions:

  1. There is no current way to tune the underlying Gossip values, but that is a goal for 0.6 to expose the low-level tunable of both Raft and Serf. We've tried to just ship very conservative defaults for now. You could always do a custom build and update those values however.

  2. This is totally possible. When a session is created, it associates with the "serfHealth" by default, but that is not necessary. You can just override the default and not associate with that check. That way it will not be used to automatically invalidate the session. Instead you can use the TTL-based sessions which are not susceptible to UDP issues.

  3. Logs primarily. Enabling telemetry is generally useful as well, since you can look for correlations between various metrics that may be impacting the system. E.g. any spikes in the gossip metrics would be interesting.

armon avatar May 07 '15 19:05 armon

Thanks @armon, that's great info. We'll look into overriding the serfHealth check association and TTL-based sessions. And enabling telemetry.

Here's a few examples of log snippets:

Node: cell_z2-14
IP: 10.10.6.88
Time: 2015/04/28 11:39:07
Agent Logs from Failed Node:
    2015/04/28 11:39:07 [WARN] memberlist: Refuting a dead message (from: cell_z2-3)
Most Informative Server Logs:
    2015/04/28 11:39:07 [INFO] memberlist: Marking cell_z2-14 as failed, suspect timeout reached
    2015/04/28 11:39:07 [INFO] serf: EventMemberFailed: cell_z2-14 10.10.6.88
    2015/04/28 11:39:07 [INFO] consul: member 'cell_z2-14' failed, marking health critical
    2015/04/28 11:39:07 [INFO] serf: EventMemberJoin: cell_z2-14 10.10.6.88
    2015/04/28 11:39:07 [INFO] consul: member 'cell_z2-14' joined, marking health alive
Node: cell_z1-23
IP: 10.10.5.89
Time: 2015/04/28 07:35:44
Agent Logs from Failed Node:
    2015/04/28 07:35:51 [ERR] http: Request /v1/session/create, error: rpc error: Check 'serfHealth' is in critical state
    2015/04/28 07:35:56 [ERR] http: Request /v1/session/create, error: rpc error: Check 'serfHealth' is in critical state
    2015/04/28 07:36:01 [ERR] http: Request /v1/session/create, error: rpc error: rpc error: Check 'serfHealth' is in critical state
    2015/04/28 07:36:06 [ERR] http: Request /v1/session/create, error: rpc error: rpc error: Check 'serfHealth' is in critical state
    2015/04/28 07:36:11 [ERR] http: Request /v1/session/create, error: rpc error: rpc error: Check 'serfHealth' is in critical state
    2015/04/28 07:36:16 [ERR] http: Request /v1/session/create, error: rpc error: rpc error: Check 'serfHealth' is in critical state
    2015/04/28 07:36:21 [ERR] http: Request /v1/session/create, error: rpc error: rpc error: Check 'serfHealth' is in critical state
    2015/04/28 07:36:24 [WARN] memberlist: Refuting a suspect message (from: cell_z1-23)
    2015/04/28 07:38:56 [INFO] memberlist: Marking cell_z2-18 as failed, suspect timeout reached
    2015/04/28 07:38:56 [INFO] serf: EventMemberFailed: cell_z2-18 10.10.6.72
    2015/04/28 07:39:35 [INFO] serf: EventMemberJoin: cell_z2-18 10.10.6.72
Most Informative Server Logs #1:
    2015/04/28 07:35:44 [INFO] serf: EventMemberFailed: cell_z1-23 10.10.5.89
    2015/04/28 07:35:44 [INFO] consul: member 'cell_z1-23' failed, marking health critical
    2015/04/28 07:36:24 [INFO] serf: EventMemberJoin: cell_z1-23 10.10.5.89
    2015/04/28 07:36:24 [INFO] consul: member 'cell_z1-23' joined, marking health alive
Most Informative Server Logs #2:
    2015/04/28 07:35:44 [INFO] memberlist: Marking cell_z1-23 as failed, suspect timeout reached
    2015/04/28 07:35:44 [INFO] serf: EventMemberFailed: cell_z1-23 10.10.5.89
Node: cell_z2-4
IP: 10.10.6.75
Time: 2015/04/28 04:10:56
Agent Logs from Failed Node:
    2015/04/28 04:10:56 [WARN] memberlist: Refuting a dead message (from: brain_z2-0)
Most Informative Server Logs:
    2015/04/28 04:10:56 [INFO] memberlist: Marking cell_z2-4 as failed, suspect timeout reached
    2015/04/28 04:10:56 [INFO] serf: EventMemberFailed: cell_z2-4 10.10.6.75
    2015/04/28 04:10:56 [INFO] consul: member 'cell_z2-4' failed, marking health critical
    2015/04/28 04:10:57 [INFO] serf: EventMemberJoin: cell_z2-4 10.10.6.75
Node: cell_z2-3
IP: 10.10.6.69
Time: 2015/04/28 00:59:49
Agent Logs from Failed Node:
    2015/04/28 00:51:57 [INFO] serf: EventMemberFailed: api_z2-0 10.10.3.66
    2015/04/28 00:52:19 [INFO] serf: EventMemberJoin: api_z2-0 10.10.3.66
    2015/04/28 00:59:39 [INFO] memberlist: Suspect stress_tests-0 has failed, no acks received
    2015/04/28 00:59:56 [WARN] memberlist: Refuting a suspect message (from: cell_z2-3)
Most Informative Server Logs #1:
    2015/04/28 00:59:49 [INFO] memberlist: Marking cell_z2-3 as failed, suspect timeout reached
    2015/04/28 00:59:49 [INFO] serf: EventMemberFailed: cell_z2-3 10.10.6.69
    2015/04/28 00:59:56 [INFO] serf: EventMemberJoin: cell_z2-3 10.10.6.69
Most Informative Server Logs #2:
    2015/04/28 00:59:49 [INFO] serf: EventMemberFailed: cell_z2-3 10.10.6.69
    2015/04/28 00:59:49 [INFO] consul: member 'cell_z2-3' failed, marking health critical
    2015/04/28 00:59:56 [INFO] serf: EventMemberJoin: cell_z2-3 10.10.6.69
    2015/04/28 00:59:56 [INFO] consul: member 'cell_z2-3' joined, marking health alive
Node: cell_z1-24
IP: 10.10.5.79
Time: 2015/04/27 19:48:37
Agent Logs from Failed Node:
    2015/04/27 19:48:43 [ERR] http: Request /v1/session/create, error: rpc error: Check 'serfHealth' is in critical state
    2015/04/27 19:48:47 [WARN] memberlist: Refuting a suspect message (from: cell_z1-24)
Most Informative Server Logs:
    2015/04/27 19:48:37 [INFO] serf: EventMemberFailed: cell_z1-24 10.10.5.79
    2015/04/27 19:48:37 [INFO] consul: member 'cell_z1-24' failed, marking health critical
    2015/04/27 19:48:48 [INFO] serf: EventMemberJoin: cell_z1-24 10.10.5.79
    2015/04/27 19:48:48 [INFO] consul: member 'cell_z1-24' joined, marking health alive

Amit-PivotalLabs avatar May 08 '15 02:05 Amit-PivotalLabs

@Amit-PivotalLabs @armon

I can confirm we see the same frequent membership loss issue in AWS. I will try to get some logs.

aj-jester avatar Jul 12 '15 09:07 aj-jester

I missed this in my inbox earlier. Based on the logs it looks 100% like UDP routing issues. I would suspect iptables, routing rules, security groups or other NAT / firewall at play.

armon avatar Jul 22 '15 22:07 armon

Thanks @armon.

/cc @fraenkel @ematpl @luan see above comment from @armon re UDP routing issues.

Amit-PivotalLabs avatar Jul 22 '15 22:07 Amit-PivotalLabs

@Amit-PivotalLabs As a heads up, the newest Consul builds from master do an additional TCP based health check. They will provide more debug output to help indicate a UDP routing issue and potentially help debug. Might be worth building from master to debug.

armon avatar Jul 22 '15 22:07 armon

Thanks, @armon and @Amit-PivotalLabs!

emalm avatar Jul 22 '15 22:07 emalm

Hi @ematpl, @armon and @Amit-PivotalLabs did you finally find the root cause of this error? we are seeing the same error in our systems, also having 3 consul servers (one of them on-prem) in different AZ. Same errors appear in AWS hosts as well as in on-prem consul server. Is there any way to increase Timeout. Checking the logs, it is almost happening every hour in each client in our case. So, it's "frequent" enough.

We are seeing same errors in our logs:

2015/08/26 15:12:23 [INFO] serf: EventMemberJoin: ip-10-44-90-183 10.44.90.183
2015/08/26 15:12:23 [INFO] serf: EventMemberJoin: ip-10-44-94-94 10.44.94.94
2015/08/26 15:12:23 [INFO] serf: EventMemberJoin: ip-10-44-94-232 10.44.94.232
2015/08/26 15:12:23 [INFO] consul: member 'ip-10-44-191-249' joined, marking health alive
2015/08/26 15:12:23 [INFO] consul: member 'ip-10-44-90-183' joined, marking health alive
2015/08/26 15:12:23 [INFO] consul: member 'ip-10-44-94-94' joined, marking health alive
2015/08/26 15:12:23 [INFO] consul: member 'ip-10-44-94-232' joined, marking health alive
2015/08/26 15:12:39 [INFO] memberlist: Marking ip-10-44-94-232 as failed, suspect timeout reached
2015/08/26 15:12:39 [INFO] serf: EventMemberFailed: ip-10-44-94-232 10.44.94.232
2015/08/26 15:12:39 [INFO] consul: member 'ip-10-44-94-232' failed, marking health critical
2015/08/26 15:12:39 [INFO] serf: EventMemberFailed: ip-10-44-93-21 10.44.93.21
2015/08/26 15:12:39 [INFO] consul: member 'ip-10-44-93-21' failed, marking health critical

bruno-loyal3 avatar Aug 26 '15 19:08 bruno-loyal3

@bruno-loyal3 This symptom almost always indicates a UDP routing issue. The best bet is to go to the nodes being marked as failed, and their logs should indicate which peer suspected it of failure. e.g. node "ip-10-44-93-21" will have a log saying something like "refuting [suspect|dead] message from ". This indicates a routing issue between "ip-10-44-93-21" and

armon avatar Aug 28 '15 01:08 armon

Having this same issue with a cluster with Consul servers in AWS and our on-prem VMware environment and some nodes consistently joining/leaving over and over with following message.

2015/09/04 14:36:54 [WARN] memberlist: Refuting a suspect message

cya9nide avatar Sep 04 '15 14:09 cya9nide

I wonder if this is a problem with AWS's "classic" network. Has anyone tried their VPC network and experience the same issue?

aj-jester avatar Sep 04 '15 23:09 aj-jester

@aj-jester: Everything we (myself, @ematpl, @fraenkel, @luan) have done has been in a VPC.

Amit-PivotalLabs avatar Sep 04 '15 23:09 Amit-PivotalLabs

@aj-jester VPC here as well. Can't figure this one out...yet.

cya9nide avatar Sep 04 '15 23:09 cya9nide

Just wanted to say that we are having the same issue in a VPC network, with around 35 consul members (5 leaders). From time to time some of the nodes leaves the cluster for a brief time (a few seconds) and that triggers consul-template to reload some services.

zonzamas avatar Nov 03 '15 15:11 zonzamas

Identical issue to #1212.

Can you try modifying the MTU of your nodes to 1500?

djenriquez avatar Nov 03 '15 16:11 djenriquez

Just want to say that issue #1335 is connected to this also.

@djenriquez I've tried setting mtu to 1500 on all nodes where consul is installed, but we still face this issue, currently running on around 17 consul members, with just 1 leader (so we can say that this has nothing to do with any leader election problem)

changwuf31 avatar Nov 15 '15 02:11 changwuf31

This looks similar to the issue I'm still having while running 0.6.3 on AWS in docker.

sstarcher avatar Jan 25 '16 14:01 sstarcher

Running 0.6.3 on AWS as well (using Docker 1.9.1) and see serf membership leaving/joing such as has been described throughout this post. Does the 0.6.3 version of Consul "expose low-level tunable of both Raft and Serf" @armon ?

draxly avatar Jan 25 '16 15:01 draxly

@draxly Likely 0.7 will expose more of the low level tunes, 0.6.3 does not. A high level of flapping almost certainly still indicates a network configuration problem as there are customers with thousands of nodes in AWS without issue. Later versions of Consul try to provide more helpful diagnostic log messages particularly in the case of misconfigured UDP connectivity.

armon avatar Jan 26 '16 02:01 armon

@armon I would love my issue to be a configuration issue. I have been running the cluster for over a year and it has been a consistent low level of annoyance. Over the weekend it went 2 days without any flapping, but lost connection on sunday evening.

sstarcher avatar Jan 26 '16 02:01 sstarcher