Detect Stale Driver Connections With a Heartbeat Timeout Monitor

Last updated: November 29, 2026

Quick Overview

Each driver app connection sends a heartbeat every few seconds. Implement a monitor that efficiently finds connections whose last heartbeat is older than a timeout, so dispatch stops sending offers to drivers who silently lost signal.

Uber
Software Engineering Fundamentals
Software Engineer
Uber
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Each driver app connection sends a heartbeat every few seconds. Implement a monitor that efficiently finds connections whose last heartbeat is older than a timeout, so dispatch stops sending offers to drivers who silently lost signal.

Mobile TCP connections often die without a FIN, so Uber gateways must detect dead drivers from silence, not from socket close. The interviewer checks why application heartbeats are needed, and an efficient data structure that does not scan every connection each tick.

What the Interviewer Expects
  • Explain why TCP alone does not quickly detect a dead mobile peer
  • Choose a timeout as a multiple of the heartbeat interval
  • Avoid scanning all connections on every check
  • Use a min-heap of deadlines with lazy invalidation, or a timing wheel
  • Handle explicit disconnects and bound memory from stale entries
Key Topics to Cover
Heartbeats
Failure detection
Heaps
Lazy deletion
Timing wheels
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would a hashed timing wheel compare for millions of connections?
  • What timeout would you pick for a 5 second heartbeat on 3G, and why?
  • How do you avoid marking an entire region offline during a brief network blip?
  • Should heartbeats carry data, such as location?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

heartbeat(conn, now), disconnect(conn), and expired(now) returning connections silent for at least timeout seconds, each reported once. Must handle hundreds of thousands of connections per gat...

High-Level Design

TCP keepalive defaults are measured in hours, and a phone entering a tunnel sends nothing, so the server needs its own liveness signal. Each heartbeat pushes (now + timeout, conn) onto a min-heap an...


Submit Your Answer
Markdown supported