Plainnotes

How often should an application heartbeat run

2025-07-30 · 2 min readNetwork

Long-lived connections need heartbeats, and the interval is usually a guess.

Two constraints. Too slow and a middlebox expires the session first; the connection is gone while you believe it is alive. Too fast and you burn traffic and battery, especially on mobile.

A workable rule: one third to one half of the NAT timeout, so 60–120 seconds against the common 300. Require two or three consecutive misses before declaring the link dead, so one blip does not trigger a reconnect storm.

Separate "I am alive" from "I can work". A heartbeat that does not touch dependencies stays green while the database is down.

On mobile, respect the platform: iOS will not run a background timer, and Android's Doze delays them. Push is the realistic mechanism there.