Your service runs on a garbage collected runtime with occasional pauses of a second or more. How should that change the way you set up failure detection and the actions taken on it?
Sketch your own answer first, then compare it with the one below.
A strong answer
Any timeout shorter than the longest pause will produce false alarms. Any timeout longer than it will take at least that long to see a real crash. So first measure the pause distribution rather than guess, and treat the tail of it as the floor for any timeout.
Then make the actions safe under false alarms. A node that comes back from a pause must not be allowed to act on authority it lost. That means fencing tokens for storage, terms for leaders, and leases that the holder checks before every action, with a safety margin for its own clock.
Also consider heartbeats that are sent from a thread the collector does not stop, or from a sidecar process, so that a pause in the application does not look like a dead machine. And reduce the pauses themselves: smaller heaps, a different collector, or moving the hot path off the managed runtime.
Sources
- Martin Kleppmann (2016). How to do distributed locking.