Try
↑ ↓ move↵ openesc close

Interview prep / Failure detection

Junior · Failure detection · System design interview question

Your process runs a background thread that sends heartbeats, but a deadlock has frozen every request handler. The monitor says the node is healthy. What is wrong, and how do you fix it?

Sketch your own answer first, then compare it with the one below.

A strong answer

The heartbeat proves only that the thread sending it is running. It says nothing about whether the node does its job. Here the process is alive at the operating system level and useless at the application level, and the monitor is reading the wrong signal.

The fix is to make the health signal depend on real work. A deep health check exercises the request path: it takes a handler, touches the database connection and returns a result within a deadline. A weaker version has the heartbeat thread read a counter of completed requests or a timestamp that the handlers update, and stop reporting if the value has not moved.

Each choice has a cost. A deep check can fail because a dependency is slow, which makes the node look dead when the fault is elsewhere, and it adds load. A progress counter is cheap, but a node with no traffic looks stalled. Pick the check that matches what you will do when it fails. A load balancer can pull a stuck node cheaply and quickly. A database failover is expensive and deserves a stronger signal.

Sources

Learn it by running it

The failure detection lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms