Database Scaling in System Design Interviews: Read Replicas, Consistent Hashing, Sharding, Partitioning & CAP/PACELC Theorem
Stop saying 'I will just shard the database' in interviews before exhausting indexing, Redis caching, connection pooling, and read replicas. Here is the exact scaling ladder.

- Prematurely proposing horizontal database sharding for a system handling 2,000 writes/second is a major red flag in System Design interviews—because a single modern PostgreSQL node with NVMe SSDs and HikariCP/PgBouncer easily handles 10,000–25,000 TPS.
- Always climb the **6-Step Database Scaling Ladder** in order: (1) Composite B-Tree Indexing + Query Tuning, (2) Connection Pooling + Redis Cache-Aside, (3) Vertical Scaling + Read Replicas, (4) Single-Node Table Partitioning, (5) Functional Federation (splitting by microservice domain), and finally (6) Horizontal Sharding via Consistent Hashing.
- When sharding is truly required (>50K writes/sec or >10 TB of hot OLTP data), choosing the **Shard Key** is the single most critical decision to avoid cross-shard joins and hot-partition bottlenecks.
1. The 6-Step Database Scaling Ladder (Walk Through This in Interviews)
When an interviewer asks 'How will our database scale from 100K users to 100M users?', walk through this progressive ladder instead of jumping straight to NoSQL or sharding:
| Scaling Stage | Bottleneck Solved | Engineering Mechanism | New Trade-Off Introduced |
|---|---|---|---|
| Stage 1: Indexing & Connection Pooling | Slow full-table scans & DB CPU spikes at 500–2K QPS | Composite B-Tree indexes matching `WHERE + ORDER BY` + PgBouncer / HikariCP | Slight overhead on `INSERT`/`UPDATE` index maintenance |
| Stage 2: Redis Cache-Aside | Read-heavy traffic (90:10 read/write ratio) up to 50K+ QPS | Cache hot entities/queries in Redis with TTL + jitter to prevent cache stampedes | Cache invalidation complexity on writes |
| Stage 3: Leader-Follower Read Replicas | Complex analytical/search reads overloading primary DB | All writes go to `Primary`; reads scale across 3–5 asynchronous `Read Replicas` | Replication Lag (10–200ms): user updates profile and immediately refreshes → fix with 'Read-Your-Own-Writes' routing |
| Stage 4: Table Partitioning (Single DB) | B-Tree index bloat on 500M+ row time-series/audit tables | Declarative PostgreSQL range partitioning (`PARTITION BY RANGE (created_at)`) per month | Queries without partition key scan all child partitions |
| Stage 5: Horizontal Sharding (Multi-Node) | Write throughput (>50K writes/sec) or storage (>10 TB) exceeds biggest single server | Hash-based (`hash(user_id) % N` or Consistent Hashing Ring with Virtual Nodes) across independent DB nodes | Loses cross-shard ACID joins, foreign keys, and global auto-increment IDs (use Snowflake 64-bit IDs or UUIDv7) |
2. Choosing the Shard Key & Solving the 'Celebrity Hot-Shard' Problem
Suppose you are designing Instagram or a concert ticketing platform and shard by `user_id` or `event_id`. What happens when Virat Kohli posts a photo or Coldplay tickets go on sale? Millions of requests hash to the exact same shard—melting one database server while the other 31 shards sit idle.
To solve the **Hot-Key / Celebrity Shard Problem** in interviews, propose three remedies: (1) **Compound Salted Shard Keys** (append a random suffix `0..9` to detected high-velocity celebrity IDs: `virat_id#0`..`virat_id#9` so writes fan out across 10 shards, and aggregate on read), (2) **Dedicated Read Cache + Request Coalescing (Singleflight)** in Redis, and (3) **Write Buffering via Kafka** for high-contention counters (likes/views).
3. Moving Beyond CAP to the PACELC Theorem (Senior Signal)
Every candidate knows the **CAP Theorem** (during a network **P**artition, choose **C**onsistency or **A**vailability). Senior candidates also cite the **PACELC Theorem**: *Even when the network is running normally (**E**lse), a distributed database must trade off **L**atency vs **C**onsistency*. For example, financial ledgers and inventory locks require **PC/EC** (strict quorum consistency both during partitions and normal operation), whereas user activity feeds and analytics use **PA/EL** (high availability and low-latency local reads).
Frequently Asked Questions
Why is UUIDv7 better than random UUIDv4 for sharded/high-scale database primary keys?
Random `UUIDv4` values scatter inserts across random pages of a B-Tree index, causing severe page splits and disk I/O thrashing once a table exceeds RAM. Time-ordered `UUIDv7` (or Twitter Snowflake 64-bit IDs) prefixes the ID with a millisecond timestamp so new rows always append monotonically to the right-most B-Tree leaf page—matching `BIGSERIAL` insert speed while remaining globally unique across shards.
How can I test my High-Level System Design skills before a real MNC/GCC interview?
Book a 1-on-1 System Design Mock Interview at `/schedule` with Uncorp's 12+ YOE principal architects to practice live whiteboard scaling, sharding, and trade-off defense.
Naitik Tailor & Uncorp Engineering Faculty
Founder & Principal Engineering Mentors (12+ Yrs Enterprise Experience) · VIT CSE '21 · Symbiosis MBA '24 · Ex-Delhivery & Ex-Aditya Birla Capital
Continue Reading in This Topic Cluster
All 73 Guides
The 2026 System Design Interview Blueprint: Designing Both Distributed Microservices & Enterprise Gen AI Systems
How to structure a 45-minute High-Level Design (HLD) interview when hiring panels test both classic distributed systems (Kafka, Redis, Sharding) and modern LLM/RAG architectures.

Hibernate, Spring Data JPA & Redis Performance Tuning: Fixing the N+1 Query Problem, Connection Pools & Cache Stampedes
The ultimate database and caching optimization guide for Java Backend developers: eliminate N+1 queries, size HikariCP connection pools, and architect Redis Cache-Aside in Spring Boot 3.

How to Crack Low-Level Design (LLD) & Machine Coding Interviews: SOLID Principles, Concurrency & Top 8 Design Problems
Why 70% of candidates who pass LeetCode DSA get eliminated in the 90-minute Machine Coding round at Flipkart, Uber, Swiggy, PhonePe & Tier-1 GCCs—and the exact framework to pass.

