| Users | Read-heavy System | Write-heavy System |
|---|---|---|
| 100 users | Single server handles reads easily; DB writes low volume | Single server handles writes; DB writes manageable |
| 10,000 users | Read cache (Redis/Memcached) added; DB handles writes well | DB write load increases; write latency may rise; caching less effective |
| 1,000,000 users | Multiple read replicas; heavy caching; DB write master may bottleneck | Write DB bottleneck; need sharding or partitioning; caching limited |
| 100,000,000 users | Global CDN for reads; geo-distributed read replicas; write DB sharded and scaled horizontally | Complex write sharding; eventual consistency; write queues and batching; high infrastructure cost |
Read-heavy vs write-heavy systems in HLD - Scaling Approaches Compared
In read-heavy systems, the first bottleneck is usually the database's ability to serve many read queries simultaneously. Without caching or read replicas, the DB CPU and disk I/O get overwhelmed.
In write-heavy systems, the bottleneck is the database's write throughput. Writes are slower and require disk persistence, so the DB write master or primary node becomes the choke point.
- Read-heavy: Use caching layers (Redis, Memcached) to serve frequent reads quickly.
- Deploy read replicas to distribute read load across multiple DB instances.
- Use CDNs to cache static content closer to users globally.
- Write-heavy: Implement database sharding or partitioning to split write load across multiple DB nodes.
- Use write queues or batching to smooth spikes in write traffic.
- Consider eventual consistency models to reduce write latency.
- Scale application servers horizontally to handle increased write requests.
Assuming 1 million users with 10 requests per second each:
- Read-heavy: 10 million reads/sec, 1 million writes/sec.
- One DB instance can handle ~10,000 QPS; need ~1000 read replicas for reads.
- Caching can reduce DB reads by 90%, lowering replicas to ~100.
- Write DB handles 1 million writes/sec; requires sharding into ~100 shards (10k writes/shard).
- Network bandwidth: 1 Gbps = 125 MB/s; high traffic needs multiple network interfaces or data centers.
Start by clarifying if the system is read-heavy or write-heavy. Then discuss bottlenecks specific to that pattern. Propose targeted solutions like caching and read replicas for read-heavy, or sharding and write queues for write-heavy. Always mention trade-offs like consistency and cost.
Your database handles 1000 QPS. Traffic grows 10x. What do you do first?
Answer: Add read replicas and implement caching to reduce load on the primary DB. For write-heavy growth, consider sharding or write queues to distribute write load.
Practice
Solution
Step 1: Understand read-heavy system definition
A read-heavy system is one where the number of read operations is much higher than write operations.Step 2: Match the description to options
It performs many more data retrievals than updates. states more data retrievals than updates, which matches the definition.Final Answer:
It performs many more data retrievals than updates. -> Option BQuick Check:
Read-heavy = more reads than writes [OK]
- Confusing read-heavy with write-heavy
- Thinking read-heavy means equal reads and writes
- Assuming read-heavy means only reads
Solution
Step 1: Identify write-heavy system needs
Write-heavy systems require fast and efficient handling of many write operations.Step 2: Match design choices to write-heavy needs
Optimize database for fast write operations. focuses on optimizing database for fast writes, which fits write-heavy systems best.Final Answer:
Optimize database for fast write operations. -> Option CQuick Check:
Write-heavy = optimize writes [OK]
- Choosing caching which helps reads, not writes
- Selecting read replicas which help read scaling
- Avoiding sharding which can help write scaling
Solution
Step 1: Analyze read-write ratio
With 90% reads, the system is read-heavy and benefits from read optimizations.Step 2: Evaluate options for read-heavy systems
Caching (Use caching layers to serve read requests.) reduces load on main database by serving frequent reads quickly.Final Answer:
Use caching layers to serve read requests. -> Option AQuick Check:
Read-heavy + caching = better performance [OK]
- Adding write nodes when writes are low
- Disabling read replicas which help reads
- Increasing write consistency unnecessarily
Solution
Step 1: Identify problem and system type
Slow writes in a write-heavy system indicate write bottlenecks.Step 2: Choose fix that improves write throughput
Asynchronous writes with queues (Implement asynchronous writes with queues.) decouple write requests, improving write speed.Final Answer:
Implement asynchronous writes with queues. -> Option AQuick Check:
Write-heavy + async writes = faster writes [OK]
- Adding read replicas which help reads, not writes
- Increasing cache size which helps reads
- Reducing consistency without understanding impact
Solution
Step 1: Understand workload distribution
70% writes means the system is write-heavy and needs to handle many updates efficiently.Step 2: Evaluate architecture options for write-heavy systems
Sharding (Implement sharding to distribute write load across nodes.) splits data and write load across multiple nodes, improving write scalability.Step 3: Analyze other options
Use a single master database with multiple read replicas. focuses on read scaling, not write. Rely heavily on caching to reduce database writes. reduces writes which is not possible here. Use eventual consistency with delayed writes only. may cause data staleness and is not always suitable.Final Answer:
Implement sharding to distribute write load across nodes. -> Option DQuick Check:
Write-heavy + sharding = scalable writes [OK]
- Choosing read replicas which help reads
- Relying on caching to reduce writes
- Ignoring consistency trade-offs
Ready to prove it?
Pass the test and this pattern moves unknown
