← 返回 doordash 的题目列表Debugging a Load Balancer Implementation and Add Round-Robin Routing
类型:online_judge
Debugging: Fix Bugs in a Load Balancer and Implement/Improve Routing
You are given an existing load balancer implementation (provided during the interview) that routes requests to a set of backends. The code contains multiple bugs.
Tasks
Find and fix multiple bugs so the load balancer works correctly in basic scenarios (adding/removing backends, routing requests, returning correct targets, etc.).
Implement/improve routing strategy:
Implement round-robin routing: consecutive requests should be distributed across backends in order.
Further improvements (bonus):
Discuss and optionally implement advanced strategies such as consistent hashing to improve stability when backends change.
What to cover
How you locate bugs (tests, logs, reasoning about edge cases).
What you fixed (logic errors, concurrency safety, state updates, empty backend list handling, etc.).
How to make round-robin correct under concurrency (if applicable).
Use the given code as the baseline; the goal is iterative fixing and enhancement, not rewriting from scratch.