Design a Production Paginated Record API
Design record creation and stable cursor-based pagination over a very large data set, including the database and index strategy.
Problem statement
For this exercise, assume a multi-tenant service creates records with an immutable record ID, tenant ID, creation timestamp, small indexed type and status fields, and a bounded opaque payload. Clients list one tenant's records newest first, optionally filtering by type and status.
The data set is much larger than memory and continues growing, so offset pagination is not acceptable.
A list traversal should use a database snapshot or commit-sequence visibility watermark so concurrent inserts do not cause skipped or duplicated records, and page tokens must be opaque, validated, scoped to the tenant and filter, and bounded in lifetime.
State and justify assumptions for traffic, total data volume, page size, read-after-create consistency, availability, regional scope, and retention. Design the create and paginated-read contracts, schema, indexes, partitioning, cursor semantics, and operational path.
Arbitrary full-text search, cross-tenant queries, bulk updates, and analytics are outside scope.
What to build
- An authorized tenant client can create one record with a stable identity and safely retry an ambiguous request without creating a duplicate.
- A client can list one tenant's records newest first, optionally filter by type and status, and continue through opaque cursor pages.
- A traversal has documented consistency semantics and does not skip or duplicate records because new records are inserted during pagination.
At scale
- Interview contract: the candidate states and justifies create and list request rates, tenant skew, total retained records, growth, and page size before sizing storage or partitions.
- Practice assumption: records have a bounded payload and a small fixed set of indexed type and status fields; arbitrary ad hoc query and full-text search are outside scope.
- Practice assumption: page tokens are opaque, tenant-and-filter scoped, tamper-resistant, carry a database snapshot or commit-sequence visibility watermark, and expire after a bounded traversal window.
- Interview contract: the candidate defines read-after-create and traversal snapshot semantics and explains their storage and availability cost.