Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Read-Only Lookup Service for a Billion Records

Serve byte ranges of a billion large, read-only records by ID with low latency, publish a new weekly version without mixing versions, and stay balanced whether traffic is uniform or skewed.

Problem statement

Design the backend of a read-only lookup service. A frontend owned by another team sends requests; you own everything behind it.

For this exercise, assume an offline pipeline produces a dataset of about 1 billion records, each with a unique 64-bit ID. Records are large, about 20 MB on average, so the dataset is about 20 PB. A request names an ID and a byte range of at most 1 MB within that record, and gets those bytes back.

Users never write; instead, once a week the pipeline produces a complete new version of the dataset in which about 2% of records have changed. Each request must be served entirely from one version.

You may take up to two days to copy and load a new version; once every part of the service has it loaded, traffic must switch to it within an hour, and you must be able to roll back to the previous version.

A new version may add or remove IDs, and a client may need to read several ranges of a record from the same version.

You may use existing storage or caching systems, but for each one you use, explain how it works inside: how it splits the data, where a request's bytes come from, and what happens when a machine fails. The offline pipeline, the frontend, authentication and billing are out of scope.

What to build

  1. Given an ID and a byte range of at most 1 MB, return exactly those bytes of the record, or a clear not-found or out-of-range error.
  2. Load each weekly version within about two days and switch traffic to it within an hour once it is fully loaded, serving every request from a single version and letting a client stay on one version across calls.
  3. Roll back to the previous version quickly if the new one is bad.

At scale

  • For this exercise, assume about 1 billion records averaging about 20 MB, about 20 PB per version, with about 2% of records changing each week.
  • For this exercise, assume up to about 50,000 requests a second, ranges averaging about 128 KB, and a first-byte latency target of 100 ms at the 99th percentile.
  • For this exercise, assume the service runs in one region with three availability zones, must stay available through the loss of one zone, and targets 99.99% availability. Traffic may be spread evenly across IDs or concentrated on a small hot set, and you won't know which in advance.