← Coinbase Interview Insights

Coinbase·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026Remote

Summary

Coinbase backend interview focused on a meaty pagination problem in Java. The question had enough layers to it that you could spend the whole session just on the core design, and then they still hit you with a follow-up on cursor-based vs offset approaches.

Questions Asked (2)

Q1

Implement a pagination system in Java for a query result set. Given a data source (possibly a streaming or aggregation query) and a page size, support fetching results page by page with stable ordering, consistent behavior when the underlying data shifts, and without loading everything into memory at once.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

This is the kind of question that looks manageable until you actually think about ties in the sort order.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: data source type, ordering guarantees, consistency needs, and memory constraints. Then propose a keyset (seek) pagination approach using a stable, unique sort key (e.g., timestamp + id) to avoid offset inefficiency and handle data shifts gracefully. Discuss trade-offs between keyset and offset pagination, and outline how to stream results in batches without loading everything into memory.

Pro tip: Mention that offset pagination breaks when data shifts (e.g., new rows inserted) and is O(n) in offset, while keyset pagination is O(log n) with proper indexing and gives stable results. Also, highlight the need for a tie-breaker in the sort key to ensure deterministic ordering.

1. Clarify requirements and constraints

Ask about the data source (SQL, NoSQL, streaming), ordering requirements, consistency expectations, and memory limits. Confirm whether the data can change between page requests and how that should be handled.

2. Choose pagination strategy

Compare offset vs. keyset pagination. Recommend keyset for large datasets and shifting data, explaining that it uses a WHERE clause on the last seen sort key to fetch the next page efficiently.

3. Design the sort key and query

Define a stable, unique sort key (e.g., created_at + id) and show how to construct the query: SELECT ... WHERE (sort_key > last_sort_key) ORDER BY sort_key LIMIT page_size. Ensure the key is indexed.

4. Handle data shifts and consistency

Explain that keyset pagination naturally handles inserts/deletes by continuing from the last seen key. Discuss snapshot isolation or read replicas if strict consistency is needed.

5. Implement streaming and memory efficiency

Describe using a cursor or iterator that fetches one page at a time, processing results incrementally. Avoid caching all pages; use lazy evaluation and close resources promptly.

Key Points to Mention

  • Keyset (seek) pagination vs. offset pagination: performance and stability trade-offs
  • Stable ordering requires a unique tie-breaker (e.g., id) in the sort key
  • Indexing the sort key to avoid full table scans
  • Handling data shifts: keyset pagination avoids duplicates/skips from inserts/deletes
  • Memory efficiency: fetch and process one page at a time, use cursors/iterators
  • Consistency options: snapshot isolation, read replicas, or accepting eventual consistency

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Extend your pagination solution to work over a derived or aggregated query. Then discuss the trade-offs between offset-based and cursor-based pagination.

Technical Trade-offsSystem DesignData Modeling
Author's notes

The aggregation follow-up tripped me up more than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, explain how to adapt pagination for a derived or aggregated query, such as using a subquery or materialized view, and ensure the pagination key is stable and unique. Then, compare offset-based and cursor-based pagination in terms of performance, consistency, and use cases, highlighting trade-offs relevant to Coinbase's scale and data integrity needs.

Pro tip: Emphasize that cursor-based pagination is generally preferred for large, frequently changing datasets like cryptocurrency transactions, but acknowledge that offset-based can be simpler for static or small datasets. Mention that Coinbase likely uses cursor-based pagination for its API to ensure consistent results and avoid performance degradation.

1. Understand the derived query

Clarify what the derived or aggregated query entails, such as grouping transactions by user or calculating daily volumes, and identify the need for a stable ordering key.

2. Adapt pagination technique

For derived queries, use a subquery or CTE to compute the aggregated results, then apply pagination on the outer query using a unique and sequential key (e.g., timestamp + ID).

3. Compare offset vs cursor

Discuss offset-based pagination's simplicity and random access versus its performance issues (deep offsets) and inconsistency (data changes). Contrast with cursor-based pagination's efficiency and consistency but limited random access.

4. Relate to Coinbase context

Apply the trade-offs to Coinbase's use case: high-volume, real-time data where consistency and performance are critical, making cursor-based pagination more suitable.

5. Conclude with recommendation

Summarize that for derived/aggregated queries, cursor-based pagination on a stable key is often better, but offset-based may suffice for static reports.

Key Points to Mention

  • Offset-based pagination: simple, supports random access, but inefficient for large offsets and inconsistent with concurrent writes.
  • Cursor-based pagination: efficient, consistent, but no random access and requires a unique, sequential cursor.
  • For derived queries, use subqueries or materialized views to precompute aggregates, then paginate on the result set.
  • Stable ordering key is crucial: use a combination of timestamp and unique ID to avoid duplicates or missing rows.
  • Performance implications: offset pagination requires scanning and discarding rows, while cursor pagination uses an index seek.
  • Coinbase context: high transaction volume and need for real-time consistency favor cursor-based pagination.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.