Try
↑ ↓ move↵ openesc close

Interview prep / Partitioning

Senior · Partitioning · System design interview question

Design the partitioning for a multi-tenant time-series store. Queries are mostly for one tenant over a time window, and ingestion is steady for every tenant.

Sketch your own answer first, then compare it with the one below.

A strong answer

Let the queries drive the key. A tenant over a time window is a range scan within one tenant. So make the tenant the first part of the key and the time the second. Then a query touches one tenant's range, and ingestion for different tenants is on different parts of the key space.

Consider the failure cases. A very large tenant would make one partition hot and large. Handle that with a bucket component: tenant, then a small bucket number, then time. A big tenant's writes spread over several buckets, and a window query fans out to just those buckets. Small tenants can use a single bucket, so their scans stay on one partition.

Then discuss splits: range partitions must split automatically when they are large or hot, and the split point should reflect load. Cover replication of each partition, secondary indexes, retention by dropping old time buckets, and how you would monitor skew. State the cost: hashing part of the key makes some cross-bucket queries fan out.

Sources

Learn it by running it

The partitioning lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms