# What is a hot key?

> A hot key is a single key that receives a large share of all traffic. Hashing spreads different keys across servers, never one key, so every request for it lands on one server, and adding servers does not help. Fixes are splitting the key, caching reads, or giving it dedicated capacity.

- Author: Zeeshan Adil (https://www.internalswithzee.com/about)
- Published: 2026-11-12
- Source: https://www.internalswithzee.com/concepts/hot-key

Also called: hot partition, hot spot.

## The problem it solves

Sharding assumes load follows the keys, and that keys are about equally busy. When one post goes viral, that assumption breaks. A hash function is deterministic: `crc32("15001")` is the same number today and tomorrow, so that post has exactly one owner. Balanced hashing spreads different keys evenly. It cannot spread one key, because one key is one hash, and one hash is one database.

## How it works

Three fixes exist, and they combine.

**Split the key.** Make the routing key longer than the id and pick a suffix per write. Instead of hashing `15001`, hash `15001:0` to `15001:31`, choosing the suffix from the comment id. Different strings hash to different places. This is called key salting or striping, and DynamoDB documents it as write sharding.

```python
route = f"{post_id}:{comment_id % stripes}"  # was: str(post_id)
```

**Cache the reads.** A viral post is usually read far more than it is written. A cache absorbs most reads, which leaves striping for the write path.

**Give it dedicated capacity.** A known hot key can be moved to its own server.

## What it does not do

- **Splitting makes reads harder.** A read must ask every server that holds a stripe and merge the results by id or time. Counters must be summed across stripes.
- **You have to know which keys are hot.** Either detect them or let the application decide. Stripe only the hot ones, so reads of other keys stay one lookup.
- **Old data stays put.** Stripes apply to new writes. Earlier rows remain on the original owner.
- **Range-ordered keys cannot be striped by suffix**, because they are ordered by the id itself.
- **More servers and more [virtual nodes](/concepts/virtual-nodes) change nothing** for a single key.

## Measured

In my [sharding challenge](/challenges/distributed-systems/where-does-each-comment-live), 200,000 comments were written to one post.

| Databases | Busiest database's share, 1 key | Busiest database's share, 32 stripes |
|---|---|---|
| 2 | 100.0% | 50.0% |
| 8 | 100.0% | 31.2% |
| 32 | 100.0% | 34.4% |

With one key, 32 databases was exactly as bad as 2. On 8 databases, 8 stripes still reached only 2 databases, because strings that differ in one character hash close together under CRC32. 64 stripes reached all 8.

On real shards, with 3,000 comments on one post and 4 databases, 1 stripe put all 3,000 on one database, while 32 stripes spread them as 1,031, 751, 468 and 750. All 3,000 read back, in order, with no duplicates, but the read asked all 4 databases instead of 1.

## Related

- Challenge to run: https://www.internalswithzee.com/challenges/distributed-systems/a-popular-post-takes-down-the-database
- Related concept: https://www.internalswithzee.com/concepts/consistent-hashing
- Related concept: https://www.internalswithzee.com/concepts/virtual-nodes
- Related concept: https://www.internalswithzee.com/concepts/request-coalescing

## Sources

- [AWS DynamoDB docs, Using write sharding to distribute workloads evenly](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-sharding.html)

