Target Duration: 60–90 seconds (~180–220 spoken words)
Goal: Deliver a clear, plain-English overview of why the project was built, its full scope, and key mental models learned, avoiding low-level implementation minutiae while dropping strategic follow-up hooks for the interviewer.
“I built MyRedis—a high-performance, in-memory key-value database from scratch in C++ without third-party frameworks, designed to deliver predictable, sub-millisecond latencies under concurrent traffic.
The system is architected around four core engineering pillars:
First, network I/O and protocol. I built a single-threaded reactor driven by Linux poll() with non-blocking sockets and state-machine buffers. To maximize throughput, I implemented a 4-byte length-prefixed binary framing protocol with TCP pipelining, allowing multiple back-to-back requests in a single TCP read to execute sequentially, alongside tagged-union serialization for strings, integers, doubles, arrays, and errors.
Second, primary storage and progressive rehashing. Instead of using standard containers that freeze the event loop during resizing, I engineered an incremental rehashing hash table using dual newer and older tables. Each query migrates a bounded batch of 128 buckets, guaranteeing strictly amortized $\mathcal{O}(1)$ operations. I used Linux-kernel-style intrusive data structures with container_of pointer arithmetic, embedding nodes directly into entries to eliminate wrapper allocations and heap fragmentation.
Third, dual-indexed Sorted Sets. To support rank queries and score filtering, I built a secondary index combining an intrusive hash table for $\mathcal{O}(1)$ score lookups with a self-balancing AVL tree augmented with subtree node counts. This enables $\mathcal{O}(\log N)$ range scans and order-statistic rank offsets without linear cursor traversal.
Finally, dual-timer eviction and async deallocation. I implemented active TTL expiration using a binary min-heap with reverse index pointers for $\mathcal{O}(\log N)$ updates, coupled with a circular doubly-linked list (DList) to prune idle client connections in $\mathcal{O}(1)$ LRU order. To prevent large key deletions from stalling the event loop, any container with over 1,000 items is detached instantly and handed off to a 4-thread worker pool for asynchronous background deallocation.
Through this project, I gained deep systems experience in non-blocking event-driven architectures, cache-conscious memory layouts, and eliminating p99 tail latency jitter.”
| What You Mentioned | Why It Was Done (The Motivation) | Problems Faced & How Solved (The Reality) | Target Deep-Dive Document |
|---|---|---|---|
| "Single-threaded reactor event loop & non-blocking I/O" | "Why choose a single-threaded reactor over a thread-per-connection or thread-pool architecture?" | "What starvation or CPU-spinning bugs occurred with partial reads/writes, and how did non-blocking state flags fix them?" | topic_01_event_loop_and_nonblocking_io |
| "Custom binary framing protocol with TCP pipelining" | "Why build a custom length-prefixed binary protocol rather than standard HTTP/JSON or RESP text?" | "How did you handle packet fragmentation and buffer shifting without corrupting back-to-back pipelined requests?" | topic_02_framing_pipelining_and_serialization |
| "Incremental rehashing with dual hash tables" | "Why implement custom incremental rehashing instead of using std::unordered_map?" |
"What race conditions or missing-key bugs occurred when searching or deleting keys while migration was actively in progress?" | topic_03_progressive_rehashing_hashtable |
| "Intrusive data structures & memory layouts" | "Why design intrusive data structures instead of standard pointer-based containers or std::shared_ptr?" |
"What memory corruption or alignment traps did you encounter when calculating structure offsets?" | topic_04_intrusive_data_structures_and_memory_layout |
| "Dual-indexed Sorted Sets combining hash tables and trees" | "Why use an augmented AVL tree with subtree counts rather than a skiplist or std::set?" |
"How did you keep tree node rank counts consistent during rotations without degrading $O(\log N)$ updates?" | topic_05_dual_indexed_sorted_sets_and_avl |
| "Active TTL eviction & background thread pool deallocation" | "Why combine a min-heap with idle connection lists instead of lazy passive expiration?" | "How did you update heap items in $O(\log N)$ without linear scans, and how did you prevent race conditions during background deallocations?" | topic_06_ttl_cache_eviction_and_thread_pool |