WIPIVERSE All articles

Heartbeat (computing)

In computer science, a heartbeat is a periodic signal generated by hardware or software to indicate normal operation or to synchronize other parts of a computer system. The heartbeat mechanism is one of the common techniques used in mission-critical systems to provide high availability and fault tolerance for network services. It operates by detecting network or system failures of nodes or daemons within a network cluster—administered by a master server—for the purpose of automatic adaptation and rebalancing. When a node fails, the remaining redundant nodes in the cluster take over its load to maintain continuous service.

A heartbeat is typically sent between machines at regular intervals measured in seconds. This signal, called a heartbeat message, is transmitted non-stop on a periodic or recurring basis from the originator's startup until its shutdown. If the receiving endpoint does not receive a heartbeat within a specified time—usually a few heartbeat intervals—the machine that should have sent the heartbeat is assumed to have failed, shut down, or become unavailable.

Heartbeat Protocol

A heartbeat protocol is generally used to negotiate and monitor the availability of a resource, such as a floating IP address. The procedure involves sending network packets to all nodes in a cluster to verify reachability. When a heartbeat starts on a machine, an election process is performed with other machines on the heartbeat network to determine which machine, if any, owns the resource. On heartbeat networks containing more than two machines, partitioning must be taken into account, as two halves of the network may be functioning but unable to communicate with one another. In such a situation, it is important that the resource be owned by only one machine—not one machine in each partition.

Because a heartbeat is intended to indicate the health of a machine, the heartbeat protocol and its transport should be as reliable as possible. A false alarm causing a failover may, depending on the resource, be highly undesirable, while rapid reaction to actual failures is also important. For this reason, heartbeats are often run over more than one transport, such as an Ethernet segment using UDP/IP combined with a serial link.

A "cluster membership" of a node is a property of network reachability: if the master can communicate with a node, that node is considered a member of the cluster; otherwise it is considered "dead." A heartbeat program as a whole consists of various subsystems:

  • Heartbeat Subsystem (HS): The subsystem that monitors the node's presence within the cluster through a series of keepalive or heartbeat messages.
  • Cluster Manager (CM): The subsystem within the cluster—usually the master server—which keeps track of the cluster members and records which resources reside on which nodes.
  • Cluster Transition (CT): The subsystem responsible for tracking when a node joins or leaves the cluster, triggering events for rebalancing and reconfiguring the master to distribute the load.

Heartbeat messages are sent periodically through techniques such as broadcast or multicast in larger clusters. Since Cluster Managers have transactions across the cluster, the most common pattern is to send heartbeat messages to all nodes and await responses in a non-blocking fashion. Because heartbeat or keepalive messages constitute the overwhelming majority of non-application-related cluster control messages, major critical systems also include non-IP protocols, such as serial ports, to deliver heartbeats.

Design and Implementation

Every Cluster Manager on the master server maintains a finite-state machine with three states for each node it administers: Down, Init, and Alive. When a new node joins, the Cluster Manager changes the node's state from Down to Init and broadcasts a "boot-up message," which the node receives and uses to execute its startup procedures. The node then responds with an acknowledgment message, after which the Cluster Manager includes the node as a member of the cluster and transitions its state from Init to Alive. Every node in the Alive state receives a periodic broadcast heartbeat message from the Heartbeat Subsystem and is expected to return an acknowledgment message within a timeout range. If the Cluster Manager does not receive an acknowledgment heartbeat message back, the node is considered unavailable, and a state transition from Alive to Down takes place. The procedures or scripts to run, and the actions taken between each state transition, are implementation details of the specific system.

Heartbeat Network

A heartbeat network is a private network shared only by the nodes in a cluster and is not accessible from outside the cluster. It is used by cluster nodes to monitor each node's status and to communicate messages necessary for maintaining the operation of the cluster. The heartbeat method relies on the FIFO (first-in, first-out) nature of the signals sent across the network. By ensuring that all messages have been received, the system ensures that events can be properly ordered.

In this communications protocol, every node sends back a message within a given interval (denoted delta), in effect confirming that it is alive and has a heartbeat. These messages are viewed as control messages that help determine that the network contains no delayed messages. A receiver node, called a "sync," maintains an ordered list of the received messages. Once a message with a timestamp later than a given marked time is received from every node, the system determines that all messages have been received, since the FIFO property ensures that messages are ordered.

In general, it is difficult to select a delta that is optimal for all applications. If the interval is too small, it requires excessive overhead; if too large, it results in performance degradation as all operations wait for the next heartbeat signal.

Related Concepts

  • Watchdog timer: An electronic timer used to detect and recover from computer malfunctions.
  • Heartbleed: A widely known security vulnerability in the OpenSSL cryptographic software library.

References

  • Hou, Zonghao; Huang, Yongxiang (2003). "Design and implementation of heartbeat in multi-machine environment." 17th International Conference on Advanced Information Networking and Applications.
  • Robertson, Alan (2000). Linux-HA Heartbeat System Design. USENIX Annual Technical Conference, SUSE Labs.
  • Li, Fei-Fei; Yu, Xiang-Zhan; Wu, Gang (2009). "Design and Implementation of High Availability Distributed System Based on Multi-level Heartbeat Protocol." IEEE.
  • Nikoletseas, Sotiris; Rolim, José D. P., eds. (2011). Theoretical Aspects of Distributed Computing in Sensor Networks. Springer.
Browse

More topics to explore

    Browse all articles