heartbeat
A small message sent at regular intervals on a long-lived connection to prove that both ends and the path between them are still alive.
In more detail
WebSockets define ping and pong control frames for it. A missed heartbeat tells a client to reconnect instead of waiting forever on a dead connection.
Example
Kafka consumers send heartbeats to the group coordinator from a background thread.Related terms
- WebSocket — A protocol that turns an HTTP connection into a long-lived, two-way channel where client and server can each send messages at any time.
- reconnection — Re-establishing a dropped long-lived connection and, where supported, resuming from the last message received.
- heartbeat.interval.ms — The consumer setting for how often, in milliseconds, the consumer sends a heartbeat to the group coordinator.
- session.timeout.ms — The consumer setting for how long the group coordinator waits without a heartbeat before declaring the consumer dead and rebalancing.
- group coordinator — The broker that manages one consumer group, tracking its members, their heartbeats and its committed offsets.
- Server-Sent Events — A standard way for a server to keep an HTTP response open and push a stream of text events to the client, in one direction only.
- half-open connection — A TCP connection that one side still thinks is open although the other side has gone away without closing it.
- ping and pong frames — WebSocket control frames for checking a connection is alive: one side sends a ping and the other must answer with a pong.
- connection gateway — A server that holds long-lived client connections and relays messages to and from them, storing nothing durable.
- health check — A regular automated test of whether a program or service is working, such as a request to its health endpoint or a command run inside its container.
Taught in
- WebSockets — Modern API Architecture: REST, GraphQL & gRPC
- Too Slow Between Two Polls — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Twenty Seconds Of Nothing — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Two Brokers Down — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Forty One Under-Replicated Partitions — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Eleven Thousand Scans That Never Arrived — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Server-Sent Events: Streaming Updates & Recovery — Production Full-Stack Engineering
- Bidirectional WebSockets: Reconnection & Heartbeats — Production Full-Stack Engineering
- Rebalancing And Its Cost — Apache Kafka & Event Streaming
- Timers Phase: setTimeout, Min-Heap Scheduling & Drift — Node.js Internals & Backend Services
- Native WebSockets: Bidirectional Real-Time Streams — Node.js Internals & Backend Services
- Worked Design Two: Scaling Chat Fan Out — Scalable System Design & Distributed Architecture
References
- RFC 6455: The WebSocket Protocol
- kafka-python KafkaConsumer
- RFC 6455: Ping and Pong frames
- HTML Standard: Server-sent events (comments)
- Patterns of Distributed Systems: HeartBeat
- gRPC documentation: Keepalive