Interview kitsBlog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2026 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Databases
Databaseshard

Replication vs sharding — what problem does each solve?

Tags
#replication#sharding#scaling
Back to categoryPractice quiz

Answer

Replication copies the same data to multiple nodes (better read scale and availability). Sharding splits data across nodes (better write/size scale), but makes queries and transactions more complex.

Advanced answer

Deep dive

Replication

Replication keeps **copies of the same dataset** on multiple nodes.

  • Primary/replica (leader/follower) is common.
  • Benefits: high availability, read scaling (read replicas), easier failover.
  • Trade-offs: replication lag (stale reads), failover complexity, write throughput still limited by the primary.

Sharding

Sharding splits the dataset into **partitions** (shards) across nodes.

  • Benefits: scale data size and write throughput.
  • Trade-offs: complex queries (cross-shard joins/aggregations), distributed transactions, resharding, choosing a good shard key.

Practical guidance

  • Start with replication for HA and read scale.
  • Consider sharding only when one node can’t handle data size/write throughput.
  • Many real deployments combine both: each shard is replicated.

Common pitfalls

Related questions

Databases
Partitioning vs sharding: what’s the difference?
#database#partitioning#sharding
Databases
Why are long transactions dangerous in production databases?
#transactions#locks#mvcc
Databases
Partitioning vs sharding: what is the difference?
Bad shard key causing hotspots (one shard gets most writes).
  • Assuming sharding is transparent (application/query patterns often must change).
  • Reading from replicas without understanding lag/consistency requirements.
  • #scaling#partitioning#sharding
    Cloud
    Horizontal vs vertical scaling: what’s the difference?
    #cloud#scaling#horizontal
    MongoDB
    Sharded MongoDB balancing (chunk migrations): what can go wrong and how do you reduce impact?
    #mongo#sharding#balancer