Module 06: Review & Cheat Sheet
[!TIP] Learning Strategy: Use this page to test yourself before an interview. If you can explain every flashcard out loud, you are ready.
1. Interactive Flashcards
Click a card to reveal the answer.
2. System Design Cheat Sheet
Caching Layers
| Layer | Technology | Latency | |:——–|:——–|:——–| | L1/L2 Cache | CPU Internal | < 10ns | | RAM | DDR4/5 | 100ns | | Edge | CDN PoP | 10-50ms | | App Cache | Redis/Memcached | 1-5ms | | Database | SSD/HDD | 1-10ms (SSD) / 100ms (HDD) |
Eviction Policies
- LRU (Least Recently Used): Default choice. Good for general workloads. O(1).
- LFU (Least Frequently Used): Good for static, popular content. Hard to implement efficiently.
- TinyLFU: High-performance, low-memory frequency tracking (Count-Min Sketch). Scan Resistant.
- ARC: Self-tuning between Recency (T1) and Frequency (T2) using Ghost Lists (B1/B2).
- Clock (Second Chance): Efficient approximation of LRU using circular buffer and reference bits.
Redis Architecture
- Single-Threaded: Uses IO Multiplexing (epoll/kqueue). No locks. Context switching is zero.
- Cluster: Sharding (Write scaling). Keys distributed via
CRC16(key) % 16384. - Persistence:
- RDB: Snapshot (Fork + Copy-on-Write).
- AOF: Append Log (fsync everysec).
Write Strategies
- Write-Through: Safe, Slow. (Bank Balance).
- Write-Back: Fast, Risky. Supports Write Coalescing. (Likes Counter).
- Write-Around: Bypasses cache. Used for Log ingestion or large files to prevent cache pollution.
- Refresh-Ahead: Pre-fetches data before expiry. (High traffic APIs).
3. Interview Checklist: “Did you remember to…”
When designing a system involving caching (e.g. Twitter Feed, News Site), use this checklist:
- Identify Hot Keys: Did you mention the Celebrity Problem (Thundering Herd)?
- Choose Eviction Policy: Did you specify LRU or TinyLFU? (Don’t say “Random”).
- Handle Expiry: Did you mention TTL + Jitter?
- Consistency Strategy: Is it Cache-Aside or Read-Through? How do you handle stale data?
- Capacity Planning: How much RAM do you need? (e.g. 10GB vs 1TB).
- Global Scale: Did you add a CDN for static assets and Edge Workers for logic?