2014-02-08 00:41:03 +00:00
---
2020-04-07 18:55:19 +00:00
layout: docs
2022-09-13 19:58:34 +00:00
page_title: Gossip Protocol | Serf
2020-04-07 18:55:19 +00:00
description: >-
2022-09-13 19:58:34 +00:00
Consul agents manage membership and broadcast messages using the Serf protocol. Learn about the differences between LAN and WAN gossip pools and how `serfHealth` affects health checks.
2014-02-08 00:41:03 +00:00
---
# Gossip Protocol
2016-01-13 22:44:01 +00:00
Consul uses a [gossip protocol](https://en.wikipedia.org/wiki/Gossip_protocol)
2021-07-22 23:20:16 +00:00
to manage membership and broadcast messages to the cluster. The protocol, membership management, and message broadcasting is provided
through the [Serf library](https://www.serf.io/). The gossip protocol
used by Serf is based on a modified version of the
[SWIM (Scalable Weakly-consistent Infection-style Process Group Membership)](https://www.cs.cornell.edu/projects/Quicksilver/public_pdfs/SWIM.pdf) protocol.
Refer to the [Serf documentation](https://www.serf.io/docs/internals/gossip.html) for additional information about the gossip protocol.
2014-02-08 00:41:03 +00:00
2014-02-20 20:26:50 +00:00
## Gossip in Consul
2014-02-08 00:41:03 +00:00
2021-07-22 23:20:16 +00:00
Consul uses a LAN gossip pool and a WAN gossip pool to perform different functions. The pools
are able to perform their functions by leveraging an embedded [Serf](https://www.serf.io/)
library. The library is abstracted and masked by Consul to simplify the user experience,
but developers may find it useful to understand how the library is leveraged.
2014-02-08 00:41:03 +00:00
2021-07-22 23:20:16 +00:00
### LAN Gossip Pool
Each datacenter that Consul operates in has a LAN gossip pool containing all members
of the datacenter (clients _and_ servers). Membership information provided by the
LAN pool allows clients to automatically discover servers, reducing the amount of
configuration needed. Failure detection is also distributed and shared by the entire cluster,
instead of concentrated on a few servers. Lastly, the gossip pool allows for fast and
reliable event broadcasts.
2014-02-08 00:41:03 +00:00
2021-07-22 23:20:16 +00:00
### WAN Gossip Pool
The WAN pool is globally unique. All servers should participate in the WAN pool,
regardless of datacenter. Membership information provided by the WAN pool allows
servers to perform cross-datacenter requests. The integrated failure detection
allows Consul to gracefully handle loss of connectivity--whether the loss is for
an entire datacenter, or a single server in a remote datacenter.
2016-09-14 17:08:34 +00:00
2020-09-01 15:14:13 +00:00
## Lifeguard Enhancements ((#lifeguard))
2016-09-14 17:08:34 +00:00
2021-07-22 23:20:16 +00:00
SWIM assumes that the local node is healthy, meaning that soft real-time packet
processing is possible. The assumption may be violated, however, if the local node
experiences CPU or network exhaustion. In these cases, the `serfHealth` check status
can flap. This can result in false monitoring alarms, additional telemetry noise, and
CPU and network resources being wasted as they attempt to diagnose non-existent failures.
2016-09-14 17:17:23 +00:00
Lifeguard completely resolves this issue with novel enhancements to SWIM.
2017-07-06 19:19:39 +00:00
For more details about Lifeguard, please see the
[Making Gossip More Robust with Lifeguard](https://www.hashicorp.com/blog/making-gossip-more-robust-with-lifeguard/)
blog post, which provides a high level overview of the HashiCorp Research paper
[Lifeguard : SWIM-ing with Situational Awareness](https://arxiv.org/abs/1707.00788). The
[Serf gossip protocol guide](https://www.serf.io/docs/internals/gossip.html#lifeguard)
also provides some lower-level details about the gossip protocol and Lifeguard.