Heuristic:4paradigm OpenMLDB Heartbeat Tuning
| Knowledge Sources | |
|---|---|
| Domains | Optimization, Distributed_Systems |
| Last Updated | 2026-10-12 16:00 GMT |
Overview
Tune tablet_heartbeat_timeout and tablet_offline_check_interval to control how quickly the nameserver detects and responds to tablet failures in dev vs production environments.
Description
OpenMLDB's nameserver monitors tablet health via heartbeat checks. Two flags control the behavior:
tablet_heartbeat_timeout(default:300000ms = 5 minutes): How long the nameserver waits before declaring a tablet offline if no heartbeat is received.tablet_offline_check_interval(default:1000ms = 1 second): How often the nameserver checks whether tablets have exceeded the heartbeat timeout.
In the onebox (dev) setup, both values are aggressively reduced to 1 ms to enable rapid failover testing. In production, the 5-minute default prevents false-positive tablet offline detection during transient network blips, but means failover takes up to 5 minutes.
Usage
Use this heuristic when configuring OpenMLDB cluster parameters for development vs production environments. Lower values speed up testing but risk false positives; higher values provide stability but slower failover.
The Insight (Rule of Thumb)
- Action: Set
--tablet_heartbeat_timeoutand--tablet_offline_check_intervalflags. - Value:
- Dev/onebox:
tablet_heartbeat_timeout=1,tablet_offline_check_interval=1(fast failover for testing) - Production: Keep defaults (
300000ms /1000ms) or reduce to60000ms if faster failover is needed
- Dev/onebox:
- Trade-off: Lower timeout = faster failover but higher risk of false-positive offline detection during network jitter. Higher timeout = more stable but slower failover.
- Compatibility: These flags are set on the nameserver role only.
Reasoning
In a distributed system, heartbeat timeouts must balance speed of failure detection against false positives caused by transient network issues. OpenMLDB's 5-minute default is conservative — it ensures that temporary network partitions or GC pauses don't trigger unnecessary tablet failovers, which would cause leader re-election and data redistribution. In development, you want fast iteration so reducing to 1ms makes failover nearly instantaneous, which is essential for testing HA scenarios without waiting 5 minutes between each test cycle.
Code Evidence
Default flag values from `src/flags.cc:32-33`:
DEFINE_uint32(tablet_heartbeat_timeout, 5 * 60 * 1000, "config the heartbeat of tablet offline. unit is milliseconds");
DEFINE_uint32(tablet_offline_check_interval, 1000, "config the check interval of tablet offline. unit is milliseconds");
Onebox dev override from `onebox/start_onebox.sh:80-82`:
elif [ "$role" = 'nameserver' ]; then
extra_opts="$extra_opts --tablet_offline_check_interval=1"
extra_opts="$extra_opts --tablet_heartbeat_timeout=1"
Standalone mode also uses aggressive timeouts from `onebox/start_onebox.sh:154-157`:
./build/bin/openmldb --endpoint="$SA_NS" --role=nameserver \
--tablet="$SA_TABLET" \
--openmldb_log_dir="$WORKSPACE/logs/standalone-ns" \
--tablet_offline_check_interval=1 --tablet_heartbeat_timeout=1