The problem started with deterministic server assignment and gradually introduced dynamic server additions and removals, requiring existing packet assignments to remain as stable as possible.
The underlying concept was consistent hashing, although the interviewer only explicitly mentioned it at the end of the interview. I managed to finish an implementation using a circular hash space, but I ran out of time to properly test and debug it. Unfortunately, I didn't pass the interview.
Interview Details
Coding: Network Packet Routing with Consistent Hashing
I was asked to implement a function that assigns incoming network packets to available backend servers. The function received a list of active server IDs and a packet identifier, such as a combination of source IP address and port, and needed to return the ID of the server responsible for handling that packet.
The initial requirement was deterministic routing: as long as the set of active servers remained unchanged, the same packet identifier should always map to the same backend server. Different packet identifiers could map to different servers, but repeated requests for the same identifier needed to produce consistent results.
Example — Deterministic Packet Assignment
The interviewer provided examples illustrating how packets should map to servers. A similar example using different identifiers would look like this: