The coding problem focused on implementing a session manager that distributes active sessions across a fixed set of servers while maintaining balanced workloads.
The central requirement was that the difference between the most heavily loaded and least heavily loaded servers could never exceed one session. The shared practice specification also included session termination, rebalancing, and sublinear update-time requirements. Overall, the difficulty felt moderate, but I did not pass the interview.
Interview Details
Round 1 — Coding: Session Manager with Load Balancing
The main problem was to design and implement a session manager responsible for assigning active sessions to multiple servers. Each active session contributes exactly one unit of load to the server hosting it. A server's load is defined as the total number of active sessions currently assigned to that server. The system must maintain the following invariant after every operation: max_server_load - min_server_load <= 1.
For example:
Server loads: [4, 4, 3] -> Valid
Server loads: [3, 3, 3] -> Valid
Server loads: [1, 1, 0] -> Valid
Server loads: [4, 2, 2] -> Invalid
Server loads: [4, 4, 3] -> Valid
Server loads: [3, 3, 3] -> Valid
Server loads: [1, 1, 0] -> Valid
Server loads: [4, 2, 2] -> Invalid
The session manager may move existing sessions between servers when necessary to restore balance.
Class Interface
The provided practice interface was structured as follows:
The manager receives a fixed collection of server IDs. The practice specification assumes:
The server list is nonempty.
Every server ID is unique.
Servers cannot be added or removed after initialization.
All servers begin with zero active sessions.
Part 2 — Start a Session
The start_session(session_id) operation assigns a new session to one of the available servers. Every successful session creation must preserve the load-balancing invariant. If multiple server assignments satisfy the requirements, any valid assignment is acceptable. Starting a session that is already active should leave the existing allocation unchanged.