Uncorp
Log In
Career & Interview Prep4 min readUpdated 2026-11-11

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.

Naitik Tailor & Uncorp Engineering Faculty
Database Scaling Ladder with Read Replicas, Consistent Hashing & Sharding Illustration
TL;DR — Key Engineering & Career Takeaways
  • 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:

Progressive Database Scaling Ladder for System Design Interviews
Scaling StageBottleneck SolvedEngineering MechanismNew Trade-Off Introduced
Stage 1: Indexing & Connection PoolingSlow full-table scans & DB CPU spikes at 500–2K QPSComposite B-Tree indexes matching `WHERE + ORDER BY` + PgBouncer / HikariCPSlight overhead on `INSERT`/`UPDATE` index maintenance
Stage 2: Redis Cache-AsideRead-heavy traffic (90:10 read/write ratio) up to 50K+ QPSCache hot entities/queries in Redis with TTL + jitter to prevent cache stampedesCache invalidation complexity on writes
Stage 3: Leader-Follower Read ReplicasComplex analytical/search reads overloading primary DBAll 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 tablesDeclarative PostgreSQL range partitioning (`PARTITION BY RANGE (created_at)`) per monthQueries 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 serverHash-based (`hash(user_id) % N` or Consistent Hashing Ring with Virtual Nodes) across independent DB nodesLoses 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.

Written & Reviewed By Uncorp Engineering Faculty

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

About Uncorp

Continue Reading in This Topic Cluster

All 73 Guides