Katkat

Implement round-robin load balancer

DoorDashSoftware Engineer · Onsite

Last updated

This question evaluates a candidate's ability to implement a strict round-robin load balancer with O(1) average operations while handling concurrent nextServer and update calls, health-check-driven skipping, and failure scenarios, testing competencies in data structures, concurrent programming, and fault-tolerant system behavior.

Implement a load balancer that distributes incoming requests across N backend servers in strict round-robin order. Requirements: (

  1. Support addServer(id), removeServer(id), and nextServer() operations in O(
  2. average time; (
  3. Skip servers marked unhealthy via markHealthy(id, isHealthy) without breaking round-robin fairness; (
  4. Ensure thread-safe behavior under concurrent calls to nextServer and server updates; (
  5. Discuss failure scenarios (e.g., a server crashes mid-selection) and how you would design health checks; (
  6. Provide unit tests and analyze time/space complexity.