UtilDojo

Popular

Menu

Database Sharding Calculator — How Many Shards Do You Need?

  • This tool runs entirely in your browser. Nothing you enter or upload is sent to a server.

Data

years

Shards

%

Leave headroom for hot shards and growth

×
Start with
8 shards
7 needed by year 3, rounded up to a power of two so you can split shards in halves

Plan

Shards needed today
2
Data at year 3
2.25 TB
Usable per shard
350 GB
70% of 500 GB
Nodes to run
24
8 shards × 3 replicas
Shards by year
YearDataShards neededNodes
Year 0500 GB26
Year 11.07 TB412
Year 21.66 TB524
Year 32.25 TB724

Order-of-magnitude figures. Shard counts assume data spreads evenly; hot shards with more traffic or bigger rows fill sooner, which is why the target utilisation leaves headroom. Resharding is expensive, so start with a power of two and split shards in halves rather than rebalancing from scratch.

About this tool

Sharding splits one large dataset across several databases so that no single machine has to hold or serve all of it. The design question is not whether to shard but how many shards to start with, because changing the count later means moving data between live databases. This calculator takes the size of your data today, how fast it grows each month, how far ahead you want to plan, and the largest amount of data you are willing to put on one shard, and turns them into the number of shards needed each year, the number to create now, and the number of machines that implies once replicas are counted.

The arithmetic is deliberately simple. Usable size per shard is the hard ceiling times your target utilisation; nobody runs a shard at 100% because hot keys, indexes and growth all need room, and 60 to 70% is a common target. Shards needed in any year is the data that year divided by that usable size, rounded up. The recommended starting count is the number needed at the end of your horizon, rounded up to a power of two. Powers of two are not magic, but splitting every shard in half is the simplest resharding there is: each new shard takes exactly half of one old shard’s key range, and no key moves more than once.

With the example inputs (500 GB today, 50 GB a month, 500 GB shards at 70%, planning three years ahead) you need 2 shards now and 7 in year three, so the tool suggests starting with 8, which with three replicas means 24 database nodes. Change the horizon to five years and the answer becomes 16. That jump is the real lesson: shard count is driven by growth and horizon more than by today’s size, and a plan that only looks a year out guarantees a migration.

The shard limit you choose matters more than any formula. Operational limits usually bind first: how long a backup or restore of one shard takes, how long a replica takes to rebuild, and how big an index fits in memory. Teams running MySQL or PostgreSQL commonly cap shards at a few hundred gigabytes to a terabyte for those reasons. Pair this page with the Consistent Hashing Visualizer to decide how keys map to shards and with the Back-of-the-Envelope Calculator to get the data growth figure in the first place.

Shards needed at 500 GB per shard, 70% target utilisation (350 GB usable)
Total dataShards neededPower-of-two start
1 TB34
2 TB68
5 TB1516
10 TB3032
20 TB5964
50 TB147256
100 TB293512

Frequently asked questions

How big should one shard be?

Small enough to back up, restore and rebuild a replica in a time you can live with, and small enough that its working set and indexes fit in memory. For MySQL and PostgreSQL that usually means a few hundred gigabytes to a terabyte; for key-value stores it can be larger. Pick the operational limit first, then the number.

Why round the shard count up to a power of two?

So that resharding is always a split in half. Going from 8 to 16 shards means each shard hands half its key range to one new shard, which is a simple, parallel copy. Going from 8 to 12 means re-mapping every key, and most of them move.

Should I start with more shards than I need?

Often yes, as logical shards. Many teams create the full target count of logical shards on day one and place several on each physical server, then move whole logical shards to new servers as data grows. Keys never move; only shards do.

What about hot shards?

This calculator sizes by data volume; a shard can also run out of CPU or I/O because a few keys get most of the traffic. Choose a shard key with high cardinality that spreads writes (user id rather than country), and keep the utilisation target low enough to absorb skew.

How do replicas affect the node count?

Each shard is normally stored on several nodes for availability, so nodes = shards × replicas. With 8 shards and 3 replicas that is 24 database processes, though several can share a machine when shards are small.

Related tools