About this tool
When one MySQL or PostgreSQL instance approaches its limits — terabytes of data, more writes than one box can absorb — the usual next step is sharding: splitting the data across many independent database instances, each owning a subset of the rows. Sharding is expensive to undo and disruptive to do, so the first question deserves arithmetic rather than folklore: how many shards do you actually need?
This calculator answers that from two independent directions. The Storage view divides your data size — total rows times average row size, multiplied by the replication factor — by the capacity ceiling of one instance, and projects the shard count 12 and 24 months out at your monthly growth rate. The Throughput view does the same with traffic: total read and write QPS divided by what one shard can carry at your target utilization, sizing on whichever direction is busier. The Growth view turns the growth rate into dates: when your shards cross 70% full, when they fill, and when the data doubles — the moments a re-shard has to be scheduled. The Keys & Skew view compares shard-key strategies (hash, range, geo, directory) and shows what a hot key does to an even distribution: the hottest shard runs at average load times (1 + skew). The Summary view combines the storage and throughput counts, takes the larger, and rounds up to a power of two — the convention that lets hash sharding scale by doubling instead of re-sharding everything — capped at 4,096.
What it does not do: measure your real per-shard capacity. The capacity presets (roughly 500 GB for a MySQL 8 instance, 1 TB for PostgreSQL) are rules of thumb, and the per-shard QPS ceilings must come from your own benchmarks. Sharding decisions also depend on transactions, joins, and operational cost that no calculator sees. Treat the output as a defensible starting point for design reviews, then validate it with a load test and a pilot shard before moving data.
How to use Database Sharding Calculator
- Storage: enter total rows, average row size, replication factor and a per-shard capacity ceiling (presets for MySQL 8 and PostgreSQL); read the shard count today and the projection for 12 and 24 months.
- Throughput: enter total read and write QPS plus what one shard can carry (from your own load test) and a target utilization; the count follows the busier direction, with a small utilization-vs-shards table.
- Growth: enter current data size, shards in service and monthly growth to get the dates your shards cross 70% and fill, plus the data-doubling time — start planning the re-shard months before the 70% line.
- Keys & Skew: compare shard-key strategies (hash, range, geo, directory) and drag the hot-key slider to see the hottest shard's load; above 30% skew a warning appears with the usual fixes.
- Summary: the combined recommendation — max of both views rounded up to a power of two — with per-shard rows, GB and QPS, fleet utilization, growth room and three pieces of advice.
Frequently asked questions
How many shards do I need?
Take the larger of two independent counts: storage (data size with replication divided by the per-shard capacity ceiling) and throughput (total QPS divided by usable per-shard QPS). Then round up to a power of two. The Summary tab does this for you from the Storage and Throughput tabs.
Why round the shard count up to a power of two?
With hash sharding, data lands on shard = hash(key) mod N. Growing from 16 to 17 shards re-hashes nearly every key, while doubling 16 to 32 moves exactly half — and consistent-hashing rings split evenly at powers of two. Powers of two turn every re-shard into a cheap, parallelizable doubling.
What per-shard capacity should I assume?
The presets use common rules of thumb: about 500 GB per MySQL 8 instance and about 1 TB per PostgreSQL instance. The real ceiling is usually RAM, not disk — the hot working set should fit the buffer pool or shared_buffers with room to spare. Latency-sensitive workloads often cap far lower.
Which shard key should I choose?
Hash for even distribution and point lookups, range for range scans and time-ordered data, geo for latency and data-residency rules, and a directory map when you need manual control. Pick a key with high cardinality that appears in almost every query — and avoid plain mod N if you plan to change the shard count.
What is hot-key skew and how do I fix it?
A few keys (one celebrity user, one big tenant, today's date in a time series) can take a disproportionate share of traffic, so the hottest shard saturates while others idle. Fixes include salting the key with a random suffix, moving to a compound shard key, caching the hot range, or giving the hot tenant a dedicated shard.
When should I reshard?
Long before shards fill. Start planning when the busiest shard crosses about 70% of capacity, and size the move as a doubling of the shard count. The Growth tab converts your monthly growth rate into that date; at 5% monthly growth, data doubles in about 14 months.
Can this replace load testing?
No. The capacity presets are rules of thumb and the QPS ceilings are inputs, not measurements — the whole calculation is only as good as the numbers you feed it. Use the calculator to frame the decision and size the plan, then validate per-shard capacity with a real benchmark before committing to a design.