← Coinbase Interview Insights

Coinbase·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Apr 2026Remote

Summary

Coinbase system design round, basically a deep dive into building an in-memory database from scratch. They kept layering on follow-ups until I was pretty deep in the weeds on transactions and TTL.

Questions Asked (5)

Q1

Design an in-memory key-value store with basic get, set, and delete operations. Walk through your data structure choices and the complexity of each operation.

System DesignAlgorithms & Data Structures
Author's notes

Started with a hash map, which is the obvious answer, and they just nodded and waited.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (e.g., expected operations, concurrency, persistence) and then propose a hash table as the core data structure. Explain how to handle collisions, resizing, and thread safety, and analyze time and space complexity for each operation.

Pro tip: Mention that while average-case complexity is O(1), worst-case can degrade to O(n) with poor hash functions or collisions, and discuss strategies like open addressing or chaining to mitigate. Also, consider bringing up real-world systems like Redis for inspiration.

1. Clarify Requirements

Ask about expected scale, concurrency needs, persistence, and any additional operations like TTL. This shows you think about the broader context.

2. Choose Data Structure

Propose a hash table (e.g., using separate chaining or open addressing) as the primary structure. Justify why it's suitable for O(1) average-case operations.

3. Detail Operations

Explain how get, set, and delete work: hashing the key, handling collisions, updating values, and removing entries. Mention resizing when load factor exceeds threshold.

4. Analyze Complexity

State average and worst-case time complexity for each operation, and space complexity. Discuss factors affecting performance (hash function quality, load factor).

5. Address Concurrency and Edge Cases

If needed, discuss thread safety (e.g., locks, concurrent hash maps) and edge cases like null keys, resizing during operations, and memory management.

Key Points to Mention

  • Hash table with separate chaining or open addressing for collision resolution
  • Average O(1) time complexity for get, set, delete; worst-case O(n)
  • Load factor and resizing strategy to maintain performance
  • Thread safety considerations (e.g., locks, concurrent data structures) if applicable
  • Space complexity O(n) and trade-offs between memory and speed
  • Real-world examples like Redis or Memcached for context

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

Q2

How would you add TTL (time-to-expiration) support to the key-value store? What are the tradeoffs between lazy expiration and eager background cleanup?

System DesignTechnical Trade-offs
Author's notes

This one I actually liked.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining the data model changes needed to store expiration times, then describe the two main expiration strategies (lazy and eager) and their tradeoffs. Finally, propose a hybrid approach that balances memory efficiency and latency, and discuss how to handle edge cases like clock skew and persistence.

Pro tip: Mention that the choice depends on workload characteristics—read-heavy vs write-heavy, memory constraints, and latency SLAs—and that a hybrid approach with periodic sampling (like Redis) is often optimal. Also, highlight the importance of making expiration atomic with reads/writes to avoid race conditions.

1. Data Model and API Changes

Explain how to store expiration timestamps alongside values, either in the value metadata or a separate index. Discuss API changes like SET with TTL and GET that respects expiration.

2. Lazy Expiration

Describe lazy expiration: on access, check if the key is expired and delete it if so. Highlight pros (no background overhead, simple) and cons (expired keys linger, wasting memory; latency spikes on access).

3. Eager Background Cleanup

Describe eager expiration: a background process periodically scans and removes expired keys. Highlight pros (frees memory promptly) and cons (CPU overhead, potential contention, complexity in distributed settings).

4. Tradeoffs and Hybrid Approach

Compare the two strategies in terms of memory, CPU, latency, and complexity. Propose a hybrid: lazy on access plus periodic sampling (e.g., random sampling of keys with TTL) to bound memory usage without full scans.

5. Edge Cases and Distributed Considerations

Discuss handling clock skew, persistence (expiration times must survive restarts), replication (expiration events propagated), and concurrency (atomic checks).

Key Points to Mention

  • Memory overhead of storing expiration timestamps and potential need for a separate index.
  • Latency impact: lazy expiration adds a check on every read, eager cleanup may cause periodic latency spikes.
  • CPU and I/O cost of background scanning, especially in large datasets.
  • Hybrid approach: lazy expiration combined with periodic sampling (e.g., Redis's active expiration).
  • Distributed systems: clock synchronization, replication of expiration, and consistency guarantees.
  • Persistence: ensuring TTLs are durable across restarts and how to handle expired keys on recovery.

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

Q3

Add transaction support to the database: BEGIN, COMMIT, and ROLLBACK, including nested transactions. How do you handle isolation and rollback semantics?

System DesignData ModelingTechnical Trade-offs
Author's notes

Hardest part of the whole interview.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: what isolation levels are needed, expected concurrency, and whether nested transactions are true savepoints or independent. Then design a transaction manager that tracks transaction state, uses a write-ahead log for durability, and implements rollback via undo logs. For nested transactions, use savepoints to allow partial rollback, and discuss isolation via locking or MVCC, highlighting trade-offs.

Pro tip: Emphasize that nested transactions are typically implemented as savepoints, not true independent transactions, and that rollback of a savepoint only undoes changes after that point. Also, mention that isolation level choice directly impacts performance and consistency, so it's a trade-off to discuss with stakeholders.

1. Clarify Requirements and Scope

Ask about expected isolation levels, concurrency, durability needs, and whether nested transactions should be true independent transactions or savepoints. This ensures you design the right solution.

2. Design Transaction Lifecycle and State Management

Define how BEGIN, COMMIT, and ROLLBACK change transaction state. Use a transaction manager to track active transactions, assign IDs, and maintain a write-ahead log (WAL) for durability and undo logs for rollback.

3. Implement Isolation Mechanisms

Choose an isolation approach: locking (e.g., two-phase locking) or MVCC. Discuss how each handles read phenomena (dirty reads, non-repeatable reads, phantoms) and the trade-offs in performance and complexity.

4. Handle Nested Transactions with Savepoints

Implement nested transactions as savepoints: each BEGIN inside a transaction creates a savepoint. ROLLBACK to a savepoint undoes changes after that point; COMMIT of a savepoint merges changes into the parent. Only the outermost COMMIT makes changes durable.

5. Address Rollback Semantics and Failure Recovery

Ensure rollback correctly undoes changes using undo logs, and handle failures (e.g., crashes) by recovering from WAL. Discuss how rollback interacts with isolation (e.g., releasing locks) and nested rollbacks.

Key Points to Mention

  • Write-ahead logging (WAL) for durability and atomicity
  • Isolation levels (READ COMMITTED, REPEATABLE READ, SERIALIZABLE) and their trade-offs
  • MVCC vs. locking for concurrency control
  • Savepoints for nested transactions and partial rollback
  • Undo/redo logs for rollback and recovery
  • Locking granularity and deadlock detection

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

Q4

How would you implement snapshot and restore functionality? What are the space and time tradeoffs of different approaches?

System DesignTechnical Trade-offs
Author's notes

Copy-on-write came up and I walked through how you'd version the underlying structure.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the scope: what data, how often, and recovery objectives. Then outline a high-level design (e.g., periodic full snapshots + incremental logs) and systematically compare approaches (full vs. incremental, in-place vs. copy-on-write) on space and time tradeoffs, tying back to Coinbase's needs for consistency, durability, and low-latency recovery.

Pro tip: Emphasize that snapshots must be crash-consistent and that restore time is often more critical than snapshot time; mention how you'd validate restores regularly to avoid silent corruption.

1. Clarify Requirements

Ask about data size, change rate, RPO/RTO, consistency needs, and budget constraints to scope the problem.

2. High-Level Design

Propose a snapshot mechanism (e.g., periodic full + incremental) and a restore process, mentioning storage and metadata management.

3. Compare Approaches

Contrast full vs. incremental, in-place vs. copy-on-write, and block-level vs. file-level, highlighting space and time tradeoffs.

4. Analyze Tradeoffs

Quantify space overhead (storage cost, duplication) and time overhead (snapshot duration, restore latency, impact on production).

5. Recommend and Validate

Choose an approach based on requirements, and describe how to test restores and monitor performance.

Key Points to Mention

  • Full vs. incremental snapshots: space savings vs. restore complexity
  • Copy-on-write and redirect-on-write for efficient point-in-time snapshots
  • Consistency: application-consistent vs. crash-consistent snapshots
  • Storage optimizations: deduplication, compression, and tiering
  • Restore time objectives (RTO) and impact on production I/O
  • Regular restore drills to ensure data integrity and process reliability

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

Q5

How would you support secondary lookups, like scanning by a field value or key prefix? What data structures would you add and what does that cost you?

System DesignAlgorithms & Data StructuresData Modeling
Author's notes

Suggested a secondary index using a sorted structure for prefix scans.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the primary data model and access patterns, then propose adding secondary indexes (e.g., inverted index or B-tree) to support lookups by field value or key prefix. Discuss the trade-offs in terms of storage overhead, write amplification, and read performance, and mention how you would keep indexes consistent.

Pro tip: Emphasize that secondary indexes are a classic space-time trade-off: you pay extra storage and write latency to gain fast reads. Also, mention that for key prefix scans, a sorted index (like a B-tree or SSTable) is more efficient than a hash index.

1. Clarify requirements and access patterns

Ask about the expected query patterns, data volume, read/write ratio, and latency requirements to determine which secondary indexes are needed.

2. Choose appropriate data structures

For field value lookups, consider inverted indexes or hash maps; for key prefix scans, use sorted structures like B-trees, skip lists, or SSTables with prefix compression.

3. Analyze costs and trade-offs

Discuss storage overhead (duplicate data), write amplification (index updates on writes), and read performance improvements. Mention consistency challenges and maintenance.

4. Address consistency and maintenance

Explain how to keep indexes in sync with the primary data, e.g., via transactions, write-ahead logs, or asynchronous updates, and how to handle failures.

5. Consider scalability and alternatives

Mention partitioning, sharding, or using a dedicated search engine (e.g., Elasticsearch) if the secondary lookups become complex or high-volume.

Key Points to Mention

  • Inverted index for field value lookups
  • B-tree or SSTable for key prefix scans
  • Storage overhead and write amplification
  • Read performance improvement and latency reduction
  • Consistency models (strong vs. eventual) for index updates
  • Partitioning and sharding strategies for scalability

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