🧵 Day 22/30 — #SystemDesign
Database Indexing: Why some queries take milliseconds… and others take forever
Your database works fine with 1K users.
At 1M users, the same query suddenly becomes slow.
Nothing changed in code.
The problem is how data is searched.
That’s where Indexing comes in.
An index is like a shortcut that helps the database find data quickly without scanning every row.
⸻
Without index:
→ DB scans entire table (Full Table Scan)
→ Time complexity grows with data
→ Slow queries at scale
With index:
→ DB jumps directly to required data
→ Faster reads
→ Efficient lookups
⸻
Simple Example
User table with 10M rows.
Query:
SELECT * FROM users WHERE email = ‘abc@gmail.com’
Without index:
→ Check all 10M rows
With index on email:
→ Direct lookup in milliseconds
⸻
Why It Matters
→ Faster search queries
→ Better performance at scale
→ Reduced database load
→ Improved user experience
⸻
Tradeoff
Indexes are not free:
→ Extra storage
→ Slower writes (index update needed)
→ Too many indexes hurt performance
⸻
Golden Rule
Index what you query often.
Not everything.
#30DaysOfSystemDesign #DatabaseIndexing #BackendEngineering
Nitin.nn @NitinthisSide_🧵 Day 21/30 — #SystemDesign Load Balancer: The silent system that keeps everything fast & alive One server handling all traffic? Works… until it doesn’t. Traffic spikes → server overload → downtime. That’s why systems use a Load Balancer. A load balancer sits between users and servers and distributes incoming requests across multiple instances. Flow: User → Load Balancer → Multiple Servers Goal: → No single server overloaded → Better performance → High availability Types (keep it simple) Layer 4 (Transport) → Works on IP + Port → Fast, less intelligent Layer 7 (Application) → Works on HTTP/HTTPS → Smart routing (headers, paths) Common Algorithms → Round Robin (equal distribution) → Least Connections (send to least busy) → IP Hash (same user → same server) → Weighted (based on server capacity) Why It Matters → Handles traffic spikes → Improves uptime → Enables horizontal scaling → Supports failover → Better latency Real Usage → AWS ELB / ALB → NGINX → HAProxy → Cloudflare Every scalable system uses one. Golden Rule Scaling = adding more servers. Load balancer = using them efficiently. #30DaysOfSystemDesign #LoadBalancing #BackendEngineering
1713174659K














