Cursor-Paginated Records Service
Design a scalable records API that supplies stable pages to an interactive client.
Problem statement
For this exercise, assume clients create and update generic records and a UI reads them in descending update-time order with stable cursor pagination. Record identifiers are immutable, writes use optimistic version checks, and invalid or expired cursors produce an explicit error.
Exclude full-text search, analytics, and cross-record transactions.
What to build
- Create, fetch, and conditionally update a record using an immutable identifier and version.
- List records in deterministic update-time and identifier order using an opaque next-page cursor.
- Return explicit conflict and invalid-cursor outcomes so the UI can refresh safely.
At scale
- Assume 500 million records, 8,000 peak writes per second, and 35,000 peak page reads per second.
- A page contains at most 100 records and should normally return within 300 milliseconds at the 95th percentile.
- An acknowledged update must be durable; list views may lag writes by up to two seconds.