Design Cursor Pagination for a Project's Task List Endpoint

Last updated: November 29, 2026

Quick Overview

Design and implement `GET /projects/{gid}/tasks` so clients can page through tens of thousands of tasks reliably while other users add and complete tasks concurrently.

Asana
Software Engineering Fundamentals
Software Engineer
Asana
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Design and implement `GET /projects/{gid}/tasks` so clients can page through tens of thousands of tasks reliably while other users add and complete tasks concurrently.

Asana's public API is used by integrations and enterprise scripts that walk very large projects, and it paginates with an opaque offset token in a `next_page` object. The interviewer checks whether you understand why numeric offsets break under concurrent inserts and how keyset pagination fixes it.

What the Interviewer Expects
  • Explains why LIMIT/OFFSET skips or repeats rows when the list changes between pages
  • Uses keyset pagination on a stable, unique sort key
  • Makes the cursor opaque and validates it
  • Caps page size and documents the default
  • Fetches limit plus one to know whether another page exists
Key Topics to Cover
keyset pagination
API design
opaque cursors
indexes
consistency
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How do you support sorting by due date, which is not unique and can change?
  • What should happen if a cursor's anchor task is deleted?
  • How would you make cursors tamper-proof or expire them?
  • How does this map onto the database index?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Return tasks in a project in a stable order, limit per page (default 50, max 100), with a token for the next page. Paging must not skip or duplicate tasks that existed for the whole walk, even if ta...

High-Level Design

Sort by (created_at, gid), which is unique and immutable. The cursor encodes the last row's key; the next query is WHERE (created_at, gid) > (?, ?) ORDER BY created_at, gid LIMIT n+1 on an index `...


Submit Your Answer
Markdown supported

Related Questions