System Designcalculator

Hot shard finder

Sharding spreads data across machines so that no one machine carries all the traffic. It works only if the shard key spreads the traffic too. A key that is fine for storage can still send most requests to one shard.

Each key goes to the shard its hash picks, so keys spread evenly but one key never splits.

Over capacity with room to spare

Shard 4 is at 131% of its capacity while the cluster as a whole would be at 50% if the load were even. It takes 32.7% of the traffic against a fair share of 12.5%.

Skew (max ÷ mean)2.62×1.00× is a perfectly even spread
Load per shard. The vertical line marks the capacity of one shard (10,000 req/s).
  1. Shard 12,560 req/s26% of capacity
  2. Shard 24,321 req/s43% of capacity
  3. Shard 36,720 req/s67% of capacity
  4. Shard 413,082 req/s131% of capacityOver capacity
  5. Shard 54,200 req/s42% of capacity
  6. Shard 63,499 req/s35% of capacity
  7. Shard 72,636 req/s26% of capacity
  8. Shard 82,983 req/s30% of capacity

Workload and sharding

Distinct keys in the data set.

The key at rank i gets traffic in proportion to 1 ÷ i^s. 0 is uniform; higher means a few keys take most of the traffic.

DynamoDB’s documentation gives a per-partition maximum of 3,000 read units and 1,000 write units per second, as one reference point.

Splits any key above a fair share into this many sub-keys, each placed on its own. Writes spread out; reading the whole key then means asking every sub-key.

Changes which shard each key hashes to. Try a few: lucky layouts hide skew.

Shards and schemes

Hottest shardShard 432.7% of traffic; a fair share is 12.5%
Over capacity1 of 83,082 req/s above capacity
Cluster load if even50%Total traffic ÷ (shards × capacity)
Traffic before a shard saturates30,577 req/sUses 38% of the cluster’s capacity

Same workload, three schemes

Skew, hottest shard and over-capacity shards for each sharding scheme, with the current workload
Shard bySkewHottest shard’s shareShards over capacity
Hash of the keySelected2.62×32.7%1 of 8
Range on a time key2.75×34.3%1 of 8
By tenant6.63×82.9%1 of 8

The time-key row assumes 30% of requests are appends. The tenant row groups keys into 100 tenants.

What it shows

Sharding spreads data across machines, but a poor shard key can still send most requests to one shard. Skew is how unevenly keys are requested. It is modelled as a power law: the key at rank i gets traffic in proportion to 1 ÷ i^s.

The tool places a workload on shards by one of three rules and shows each shard’s load against its capacity. The layout is seeded, so the same inputs always give the same picture.

How to read it

  • Each bar is one shard. The vertical line is its capacity. A shard past it is labelled “Over capacity”.
  • “Hottest” marks the busiest shard. Skew is its load divided by the average; 1.00× is a perfectly even spread.
  • “Traffic before a shard saturates” is how far total traffic can grow before the first shard reaches capacity.
  • “Same workload, three schemes” compares hash, time range and tenant on your inputs.
  • A salt count above 1 splits busy keys into sub-keys. Reading one of those keys then takes a lookup per sub-key.
  • Change the layout seed to see another hash placement. If skew shows up only on some seeds, luck was hiding it.

Questions

Will adding shards fix a hot shard?

Only if the load is many warm keys landing unluckily. If one key sends more than a single shard can serve, a hash still puts all of it on one shard, however many shards there are. The tool says so when this happens. Split the key, cache it, or both.

Why does a time-ordered key overload the newest shard?

A range-sharded key space puts neighbouring keys on the same shard. A timestamp or sequence number only grows, so every new write falls just past the end of the key space, in the last range. Hashing the key, or adding a prefix such as a bucket number, breaks that up at the price of efficient time-range scans.

What does salting cost?

Writes to a salted key spread across several shards, as the DynamoDB write-sharding guidance describes with random suffixes. To read everything under the key you must query every suffix and merge the results, so reads of that key take more lookups. Salting also makes it harder to find one specific item unless the suffix can be calculated from something you know.

Is a power law a realistic model of my traffic?

It is a common starting point. Breslau and colleagues found that web page requests follow a Zipf-like distribution whose exponent differs from one trace to another, so measure your own. Real traffic also changes over time, which this tool does not model.

Learn it properly

Sources

Last updated

More tools

All tools

Your first senior-level
lesson is free.

Choose a course, open a free lesson, and explore an idea you’ve wanted to understand.