Graduate Java Developer
- Posted
- 14 Oct 2026
Summary
I faced a load balancer design problem during a Graduate Java Developer interview at Revolut.
How it went
Interview Question: Implement a Load Balancer in Java
I encountered this question during a Graduate Java Developer interview at Revolut and thought it would be interesting to discuss with the LeetCode community.
Problem Statement
Implement a simple load balancer that acts as a registry for services and their instances.
The load balancer should maintain a record of registered service instances, identified by their addresses.
Requirements
- Register an instance: The load balancer should allow a new service instance to be registered using its address.
- Unique addresses: Each address must be unique. Registering the same address more than once should not be allowed.
- Maximum capacity: The load balancer should accept a maximum of 10 addresses.
- Service registry: The registry should be updated whenever a new service instance comes online.
Example
Suppose we register the following addresses:
register("192.168.1.1");
register("192.168.1.2");
register("192.168.1.1"); // Duplicate address
The first two registrations should succeed, while the third should be rejected because the address is already registered.
Once 10 unique addresses have been registered, any additional registration should be rejected.
Questions for discussion
- Which Java data structure would you use to store the registered addresses, and why?
- How would you prevent duplicate registrations?
- How would you enforce the maximum capacity of 10 addresses?
- How would you design the
register()method to handle these cases cleanly? - What additional considerations would matter if multiple threads tried to register instances simultaneously?
I'd be interested to see different Java implementations and hear how others would approach this problem in a coding interview.
Questions asked (1)
- 01
Load Balancer Implementation
Data Structures & Algorithms
Problem Statement
Implement a simple load balancer that acts as a registry for services and their instances.
The load balancer should maintain a record of registered service instances, identified by their addresses.
Requirements
- Register an instance: The load balancer should allow a new service instance to be registered using its address.
- Unique addresses: Each address must be unique. Registering the same address more than once should not be allowed.
- Maximum capacity: The load balancer should accept a maximum of 10 addresses.
- Service registry: The registry should be updated whenever a new service instance comes online.
Example
register("192.168.1.1"); register("192.168.1.2"); register("192.168.1.1"); // Duplicate addressThe first two registrations should succeed, while the third should be rejected because the address is already registered.
Once 10 unique addresses have been registered, any additional registration should be rejected.