The Load Balancer
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
Implement a LoadBalancer via an ops list. Operations: ['add_server', id], ['remove_server', id], ['get_server']. get_server returns the next server in round-robin over the current servers in the order they were added. Return the result list: None for add/remove, the server id for get_server. If get_server is called with zero servers, the behavior is undefined (test data will not hit this).
Summary
Distribute incoming requests evenly across available servers.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.