Components · Data and messaging

Key-value store

Partitions with per-partition limits.

Lesson
Coming soon
Zone
data
Place it
4 cr on the blank canvas, free inside a problem

At a glance

Did you know
Key-value stores spread keys over partitions; one very popular key can overload a single partition.
Rule of thumb
Cache hot keys or add a random suffix to spread them across partitions.
Watch out
A hot partition throttles while average load looks low.

Problems that start with it

  • URL shortener 4,000 req/s, 95% redirects. Popular links are far more popular than the rest.
  • Key-value store out of partitions A session store spreads keys over 4 partitions that each handle 400 operations a second. Traffic is 2,500 a second.
  • One viral key A URL shortener where one link went viral: its partition melts while the rest are idle.
  • Leaderboard: one hot key, one shard One viral link gets most of the reads. The cache in front of the store hits only 60%, and its single shard handles at most 1,500 operations a second.
  • Google Docs: everyone opens the same document An all-hands document is opened by thousands of people at once. Documents are spread over partitions, and this one sits on a single partition.
  • Java cold starts at launch A Java Lambda (Spring) takes 3 s to initialise. At 30 s a launch email quintuples traffic for 20 s: every request without a warm environment starts a new one and waits for INIT, which needs still more environments.
  • One function starves the account Two Lambda functions share an account: the customer API (about 100 ms a call) and a report export (about 4.5 s a call). Exports run 240 a second at month end. Neither has reserved concurrency, and the account limit is 1,000.
  • Trending videos: top-K at 30,000 views a second Asked at YouTube and Twitter/X. Each view increments a per-video counter row in a key-value store, and the trending page reads those counters. Views follow a power law, so one viral video hammers one partition; at 10 s a new release doubles views.

And 3 more on the problems page.

Full lesson coming soon

Lessons are being added one component at a time: how it works, its settings, a live exercise to break and fix it, interview questions and a short check. See the Circuit breaker lesson for what one looks like.