Core Concept

Database Sharding and Partitioning

Sharding breaks massive single-node persistent volumes into a cluster of independent nodes, scaling write throughput horizontally at the cost of distributed query complexity.


What:

Horizontal partitioning (sharding) splits single tables horizontally into separate database servers; vertical partitioning splits table columns into separate tables.

Primary purpose:

Scaling write throughput and storage capacity beyond the physical hardware limits of a single master server.

Usually used for:

High-volume transactional databases, heavy social timeline layers, and multi-tenant SaaS backends.

How should I think about this inside system architectures?

🔑 The Sharding Key Rule

Select a key (e.g. `user_id` or `tenant_id`) that routes over 90% of your common queries to a single shard, entirely avoiding cross-shard lookups.

⚖️ Even Distribution

Choose keys with high cardinality to distribute storage and write QPS uniformly across your database node pool.

🧬 Application Routing

Move routing logic either into an application middleware library (e.g., Vitess) or deploy a dedicated proxy tier (e.g., Citus).