Read vs Write Patterns
Understanding your read/write ratio is key to choosing the right architecture.
1The Library vs Newspaper Analogy
Write-Heavy (Newspaper): New content constantly arriving, needs to be recorded fast. Readers can wait a bit for today's news to be organized.
Your database needs match your use case!
2Read-Heavy Workloads
Optimization Strategies
Store frequently read data in memory (Redis, Memcached). Avoid hitting DB.
Copy data to multiple read-only databases. Distribute read load.
Duplicate data to avoid JOINs. Trade storage for speed.
Cache static content at edge locations worldwide.
3Write-Heavy Workloads
Optimization Strategies
Buffer writes in memory, batch flush to database.
Sequential writes are faster than random. Log-structured storage.
Distribute writes across multiple database servers.
Accept write, queue for processing, return immediately.
4Read/Write Ratio Examples
5Balancing Reads and Writes
| Technique | Helps Reads | Helps Writes | Trade-off |
|---|---|---|---|
| Caching | ✓✓✓ | - | Cache invalidation complexity |
| Read Replicas | ✓✓ | - | Replication lag |
| Sharding | ✓ | ✓✓✓ | Cross-shard queries complex |
| Denormalization | ✓✓ | ✗ | Data duplication, sync issues |
| Async Writes | - | ✓✓ | Eventual consistency |
6Interview Questions
7Key Takeaways
8Interview Follow-up Questions
Interview Follow-up Questions
Common follow-up questions interviewers ask
9Test Your Understanding
Test Your Understanding
5 questions
A typical e-commerce product catalog has which read/write ratio?
Which optimization is MOST effective for a write-heavy logging system?
What is the main trade-off of denormalization?
Read replicas help with which type of scaling?
When would you consider using CQRS?