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.
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%.
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
Same workload, three schemes
| Shard by | Skew | Hottest shard’s share | Shards over capacity |
|---|---|---|---|
| Hash of the keySelected | 2.62× | 32.7% | 1 of 8 |
| Range on a time key | 2.75× | 34.3% | 1 of 8 |
| By tenant | 6.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
- DeCandia, G. et al. (2007). Dynamo: Amazon’s highly available key-value store. SOSP 2007, Section 6.2, ensuring uniform load distribution.
- Amazon DynamoDB Developer Guide: best practices for designing and using partition keys effectively.
- Amazon DynamoDB Developer Guide: using write sharding to distribute workloads evenly.
- Breslau, L. et al. (1999). Web caching and Zipf-like distributions: evidence and implications. IEEE INFOCOM 1999.
Last updated
More tools
All tools- estimatorBack-of-envelope estimatorTurn daily users into requests per second, storage and bandwidth, with the working shown.Open tool
- simulatorConsistent hashing simulatorA hash ring with virtual nodes: key spread per node, and how many keys move when the cluster changes.Open tool
- estimatorQueue latency estimatorWhy latency explodes as servers get busy: utilisation, waiting time and Little’s law.Open tool