This was a single problem with five escalating parts.
Start by clarifying requirements and constraints, then outline a high-level design with core data structures and algorithms. Implement the solution incrementally, explaining trade-offs and handling edge cases like capacity limits and eviction.
Pro tip: Focus on the stickiness requirement: it often conflicts with least-loaded routing, so discuss how to balance them (e.g., sticky sessions with fallback to least-loaded when capacity is reached).
Ask about expected scale, connection duration, stickiness definition, and shutdown semantics. Confirm whether eviction should be graceful or immediate.
Choose structures to track server loads, connection-to-server mappings, and object-to-server stickiness. Consider heaps or balanced trees for efficient least-loaded lookup.
Write code for CONNECT (routing with stickiness and capacity), DISCONNECT (updating loads and mappings), and SHUTDOWN (evicting connections and redistributing).
Address scenarios like all servers at capacity, sticky object with no available server, and shutdown with active connections. Discuss fallback strategies.
Discuss time/space complexity, consistency vs. availability, and potential optimizations (e.g., lazy updates, caching).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.