Implement a load balancer that distributes incoming requests across N backend servers in strict round-robin order. Requirements:
(
-
Support addServer(id), removeServer(id), and nextServer() operations in O(
-
average time;
(
-
Skip servers marked unhealthy via markHealthy(id, isHealthy) without breaking round-robin fairness;
(
-
Ensure thread-safe behavior under concurrent calls to nextServer and server updates;
(
-
Discuss failure scenarios (e.g., a server crashes mid-selection) and how you would design health checks;
(
-
Provide unit tests and analyze time/space complexity.