LoadBalancer Class
Design a LoadBalancer class that supports registering backend instances. Each backend instance address must be unique; the same address cannot be registered twice. The load balancer should accept a maximum of 10 backend instances. The implementation should be production-ready, as the LoadBalancer will be released as a library. Develop an algorithm for the get() method that, when invoked multiple times, randomly selects and returns one of the registered backend instances.
AI interview prep
Core dilemma
Balancing simplicity and robustness in a limited-scope, in-memory load balancing library, ensuring correct registration and fair random distribution.
3 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
LoadBalancer Class
Design a LoadBalancer class that supports registering backend instances. Each backend instance address must be unique; the same address cannot be registered twice. The load balancer should accept a maximum of 10 backend instances. The implementation should be production-ready, as the LoadBalancer will be released as a library. Develop an algorithm for the get() method that, when invoked multiple times, randomly selects and returns one of the registered backend instances.