What is sharding and why shard over vertical scaling?
horizontal partitioning rationale.
sharding splits one dataset across servers by a shard key so each holds a subset; you shard because vertical scaling hits hardware ceilings, gets costly, and remains a single point of failure.
WHAT THIS TESTS This checks whether you understand horizontal partitioning and can justify it against the simpler-sounding option of just buying a bigger server.
A GOOD ANSWER COVERS Sharding is horizontal partitioning of a single logical database across multiple servers, called shards, where each shard holds a distinct subset of the rows chosen by a shard key, such as user id or geographic region. Because each shard stores only part of the data and handles only its portion of traffic, sharding distributes storage capacity, read load, and crucially write load across many machines. You choose sharding over vertical scaling, which means upgrading one server with more CPU, memory, or disk, for several reasons. Vertical scaling has a hard physical ceiling; eventually no single machine is big enough. Its cost grows disproportionately, since top-tier hardware is far more expensive per unit of capacity. And a single server remains a single point of failure. Sharding scales out using cheaper commodity nodes and can grow near-linearly by adding shards, while also spreading write throughput that a single primary could never sustain alone.
COMMON WRONG ANSWERS Confusing sharding with replication; sharding splits data into disjoint subsets, replication copies the whole dataset. Ignoring the operational complexity sharding adds, such as cross-shard queries, joins, transactions, and rebalancing. Forgetting that a poor shard key creates hot spots. Claiming vertical scaling is always cheaper, when at scale it becomes prohibitively expensive and still caps out.
LIKELY FOLLOW-UPS How do you choose a good shard key to avoid hot spots? What is the difference between range and hash sharding? How do you run a query that spans shards? How do you rebalance or resplit shards as they grow?
ONE CONCRETE EXAMPLE A social app outgrows its largest single database server. Sharding users by a hash of user id across ten nodes means each node stores roughly one tenth of users and handles one tenth of writes, so the system scales by adding more shards rather than chasing an ever-bigger, ever-pricier single machine.
Read the original → digitalocean.com
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.