Problems / Databases, medium

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.

Free to open. Runs in your browser, no sign-up.

Your goals

Success ≥ 99%, p99 ≤ 300 ms.

The traffic

2,500 requests a second for 30 seconds: 80% reads, 20% writes.

The system

What each component does in this design, and what calls it. The simulator mimics each one from these settings.

ComponentIts job hereSettings
Load balancerLoad balancerTraffic enters here.Calls API.Layer 4 balancers route by IP and port; layer 7 balancers read HTTP and can route by path or header.–
APIApp serviceLoad balancer forwards to it.Calls Session store.Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s.3 replicas × 200 slots · timeout 1.0 s
Session storeKey-value storeAPI calls it.Key-value stores spread keys over partitions; one very popular key can overload a single partition.4 partitions × 400 ops/s

Hints

Try it first. Open one hint at a time if you get stuck.

Hint 1

Throughput = partitions × per-partition limit.

Hint 2

4 × 400 = 1,600 < 2,500.

One way to solve it

Add partitions (shards).

More databases problems