- Concurrency: Threads vs Processes, AsyncIO Event Loops, and GIL limitations.
- Thread Safety: Locks, Semaphores, and Deadlock simulations (Dining Philosophers).
- Scalability: Vertical vs Horizontal Scaling, Load Balancing algorithms.
- Distributed Data: CAP Theorem, Replication Lag, Sharding (Range vs Hash), and Saga Pattern.
- Resiliency: Circuit Breakers (Netflix Hystrix), Retry with Jitter, and Chaos Engineering.
- Advanced Structures: Bloom Filters, HyperLogLog, and Geospatial QuadTrees (Uber).
- Production Inference: vLLM (Continuous Batching), KV Caching (PagedAttention), and LoRA Adapters.
- Recommender Systems: Two-Tower Architecture (YouTube/Netflix style).
- RAG Deep Dive: Vector Indexing (HNSW), Chunking strategies, and Embeddings.
A set of common interview questions implemented with both "Naive" (Bad) and "Optimal" (Scaled) approaches to demonstrate the difference.
| Component | The "Naive" Way (Fail) | The "Optimal" Way (Pass) |
|---|---|---|
| Q4. WhatsApp | Polling DB every 1s | WebSockets + Store-and-Forward |
| Q6. News Feed | Pull Model (Slow Read) | Push Model (Fan-out on Write) |
| Q7. Google Drive | Re-uploading 1GB Files | Block-level Deduplication |
| Q8. YouTube | Sending full 4K.mp4 | Adaptive Bitrate (HLS/DASH) |
| Q9. Leaderboard | ORDER BY score |
Redis Sorted Sets (SkipList) |
| Q10. Ticketmaster | Race Condition (Oversell) | Optimistic Locking / Lua Scripts |
| Q11. Analytics | INSERT every click | Stream Windows (Flink/Spark) |
| Q12. Trending | HashMap (OOM) | Count-Min Sketch (Probabilistic) |
| Q13. Kafka | In-Memory Queue | Distributed Append-Only Log |
| Q15. Payments | Retrying on Timeout | Idempotency Keys |
I included references to where these patterns are used in production systems:
- Uber/Google Maps: QuadTrees & Geohashing.
- Netflix: Chaos Monkey & Hystrix.
- Discord: Consistent Hashing (Ring).
- Amazon: Saga Pattern for Order Fulfillment.
- Apple Intelligence: LoRA Adapters for On-Device AI.
- YouTube: Two-Tower Neural Networks for Recommendations.
-
Setup:
make setup
-
Start Learning:
make run
(Navigate the CLI menu to choose lessons)
-
Run Tests:
make test -
Clean:
make clean
Contributions are welcome. Please read CONTRIBUTING.md for details on the workflow.
- Fork the repo
- Create your feature branch (
git checkout -b feat/amazing-feature) - Run tests (
make test) - Commit your changes (
git commit -m 'feat: Add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
Created for self-education and shared for the community