Mercurial
diff grok_interview/README.md @ 51:68fa88ac73fe
Interview prep for xAI
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Mon, 15 Dec 2025 19:55:17 -0800 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/grok_interview/README.md Mon Dec 15 19:55:17 2025 -0800 @@ -0,0 +1,43 @@ +# Distributed Cache (Focus: Hashing & System Logic) + +- Question: Implement a Cache Router + + Level 1 (Easy - Modulo Hashing): Write a function that maps a key (string) to one of N servers. + + Task: Implement getServerIndex(key, serverCount). + + Expected Logic: Simple hash modulo: hash(key) % serverCount. + + Critique: The interviewer will ask, "What happens to the existing keys if we add one server (change N to N+1)?" (Answer: Almost all keys get remapped, causing a massive cache miss storm). + + Level 2 (Medium - Consistent Hashing): Solve the remapping problem. Implement a ConsistentHash class. + + Task: Map servers to points on a circle (0 to 360 degrees or a large integer range). Map keys to the same circle. A key belongs to the first server it encounters moving clockwise. + + Goal: Prove that adding a server only requires remapping the keys that fall between the new server and its predecessor. + + Level 3 (Hard - Virtual Nodes): The servers have uneven capacity, or the data distribution is skewed (some segments of the ring have way more keys). + + Task: Modify the class so that each physical server exists at multiple points on the ring (e.g., "Server A" is at positions 10, 150, and 290). + + Goal: Distribute load more evenly and handle "hot spots" better. + +--- + +Questions: + + - Async + - Threads + - DB + - Cache + - KV + - Distribution + + +--- + +FE + + - Fetching URL + - Storing it as useMemo and what not. +