← Databricks Interview Insights

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

SeniorPrefer not to say
Jun 2026

Summary

Databricks system design round focused entirely on designing a file system from scratch. No shortcuts allowed, they explicitly said you can't just say 'use S3 as the blob store' and call it a day. It went deep fast.

Questions Asked (5)

Q1

Design a file system from scratch, covering the on-disk layout including inodes, directory entries, and free-space management. You cannot use an existing blob or object store as a building block.

System DesignTechnical Trade-offs
Author's notes

The constraint about not using an object store tripped me up early.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then design a layered file system: begin with the block device abstraction, then define the superblock, inode table, data blocks, and directory structure. Discuss trade-offs for each component (e.g., inode allocation, directory entry format, free-space management) and how they impact performance, scalability, and reliability.

Pro tip: Emphasize crash consistency and recovery mechanisms (e.g., journaling or copy-on-write) early, as Databricks values robust data systems. Also, relate design choices to real-world workloads like large-scale analytics.

1. Clarify Requirements and Assumptions

Ask about expected scale, workload characteristics (e.g., file sizes, access patterns), durability, and performance goals. State assumptions to guide the design.

2. Design On-Disk Layout

Define the superblock, inode structure (metadata, pointers to data blocks), and data block allocation. Decide between inode-based (e.g., ext4) or other layouts.

3. Design Directory Structure and Naming

Choose a directory entry format (e.g., linear list, B-tree) and explain how path resolution works. Discuss trade-offs between simplicity and lookup performance.

4. Implement Free-Space Management

Select a method (e.g., bitmap, free list, B-tree) to track free blocks and inodes. Explain allocation and deallocation strategies, and how to handle fragmentation.

5. Address Reliability and Performance

Discuss crash consistency (journaling, COW), caching, and concurrency. Consider how the design scales with large files and many files.

Key Points to Mention

  • Inode structure: metadata (permissions, timestamps, size) and block pointers (direct, indirect, double-indirect) for efficient large file support.
  • Directory entry organization: trade-offs between linear search and B-tree for fast lookups, and how to handle large directories.
  • Free-space management: bitmap vs. free list vs. B-tree; trade-offs in terms of space overhead, speed, and scalability.
  • Crash consistency: journaling or copy-on-write to ensure atomic updates and quick recovery.
  • Caching and buffering: page cache, inode cache, and write-back policies to improve performance.
  • Scalability considerations: how the design handles millions of files, large files, and concurrent access.

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

Q2

How would you support fast directory listing with pagination when a directory contains a very large number of entries?

System DesignAlgorithms & Data Structures
Author's notes

Cursor-based pagination was the right answer here and I got there eventually, but I wasted time talking about offset-based pagination first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements such as directory size, expected latency, and consistency needs. Then propose a design that avoids full scans by using an index or sorted structure, and discuss pagination techniques like cursor-based pagination with stable ordering. Finally, address scalability and trade-offs, including caching and distributed storage considerations.

Pro tip: Mention that cursor-based pagination with a stable sort key (e.g., inode number or name) avoids the O(n) offset problem and handles concurrent modifications gracefully. Also, highlight that Databricks often deals with cloud storage, so leveraging object store listing APIs with continuation tokens is key.

1. Clarify Requirements and Constraints

Ask about directory size, expected read/write patterns, latency requirements, and consistency guarantees. This scopes the problem and shows you think before coding.

2. Propose an Indexing Strategy

Suggest maintaining a sorted index of directory entries (e.g., B-tree or LSM-tree) to allow efficient range scans. For cloud storage, use the object store's native listing with continuation tokens.

3. Design Pagination Mechanism

Use cursor-based pagination where the cursor encodes the last seen key (e.g., name or inode). This avoids offset scans and provides stable results even with concurrent modifications.

4. Address Scalability and Performance

Discuss partitioning the index, caching frequently accessed pages, and using asynchronous prefetching. Consider distributed systems like HDFS or S3 and how they handle large listings.

5. Discuss Trade-offs and Edge Cases

Compare cursor vs. offset pagination, mention handling of deletions/insertions during pagination, and consistency models (e.g., snapshot isolation).

Key Points to Mention

  • Cursor-based pagination with a stable sort key (e.g., name, inode) to avoid O(n) offset scans.
  • Use of B-trees or LSM-trees for efficient range queries on directory entries.
  • Leveraging cloud object store APIs (e.g., S3 ListObjectsV2) with continuation tokens for scalable listing.
  • Caching and prefetching to reduce latency for subsequent pages.
  • Handling concurrent modifications and consistency guarantees (e.g., snapshot isolation).
  • Partitioning or sharding the directory index to distribute load.

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

Q3

How do you implement recursive directory deletion that is atomic, handles very large subtrees efficiently, and stays safe under concurrent access?

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

This was the meatiest part of the whole interview.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what 'atomic' means (all-or-nothing visibility, crash consistency), the scale of subtrees, and concurrency model. Then propose a design that uses rename-based atomicity for the top-level directory, an iterative traversal to avoid stack overflow, and a locking or versioning scheme to handle concurrent access. Finally, discuss trade-offs between simplicity, performance, and safety.

Pro tip: Mention that true atomicity for recursive deletion is often achieved by renaming the directory to a temporary name first, making it invisible to other operations, then deleting it asynchronously. This avoids partial visibility and reduces lock contention.

1. Clarify requirements and constraints

Ask about the definition of atomicity (e.g., crash consistency, isolation from concurrent readers/writers), expected subtree sizes, and concurrency patterns. This ensures you address the right problem.

2. Design for atomicity

Propose using an atomic rename of the target directory to a unique temporary name (e.g., .trash-uuid) to instantly remove it from the namespace. Then delete the renamed directory in the background, ensuring that if a crash occurs, a cleanup process can resume.

3. Handle large subtrees efficiently

Use an iterative traversal (e.g., explicit stack or queue) instead of recursion to avoid stack overflow. Consider parallel deletion of independent subdirectories to improve throughput, but bound concurrency to avoid resource exhaustion.

4. Ensure safety under concurrent access

Employ locking (e.g., per-directory locks or a global lock with fine-grained granularity) or use versioning/leases to prevent concurrent modifications during deletion. Discuss how to handle operations that race with deletion (e.g., open file handles, new file creation).

5. Discuss trade-offs and failure recovery

Compare approaches: rename-based vs. in-place deletion, locking vs. optimistic concurrency. Explain how to recover from partial deletions (e.g., journaling, idempotent cleanup) and the impact on performance and complexity.

Key Points to Mention

  • Atomic rename to a temporary location as a way to achieve all-or-nothing visibility.
  • Iterative traversal (BFS/DFS with explicit stack) to avoid recursion depth limits.
  • Concurrency control: per-directory locks, read-write locks, or optimistic concurrency with version numbers.
  • Handling open file descriptors and processes that may still access files during deletion (e.g., POSIX unlink semantics).
  • Crash consistency and recovery: journaling, idempotent operations, and background cleanup.
  • Performance considerations: parallel deletion, I/O batching, and avoiding unnecessary metadata operations.

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

Q4

How do you ensure crash consistency in your file system design? Walk through journaling, copy-on-write, and fsync semantics.

System DesignTechnical Trade-offs
Author's notes

I defaulted to journaling because it's what I know best.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining crash consistency and why it matters, then compare journaling, copy-on-write, and fsync semantics in terms of their mechanisms, trade-offs, and guarantees. Conclude by discussing how you would choose or combine these techniques based on workload requirements and performance constraints.

Pro tip: Emphasize that fsync is not just about flushing data but also about ordering and durability guarantees, and mention that many real-world systems (e.g., databases) use a combination of techniques like journaling with fsync to balance performance and consistency.

1. Define crash consistency and its importance

Explain that crash consistency ensures the file system remains in a valid state after a crash, preventing data corruption or loss. Highlight that it's critical for reliability and data integrity.

2. Explain journaling

Describe how journaling writes metadata (and optionally data) to a log before committing changes to the main file system, allowing recovery by replaying the log. Mention trade-offs: performance overhead vs. faster recovery and consistency.

3. Explain copy-on-write (COW)

Describe how COW never overwrites data in place; instead, it writes new data to unused blocks and atomically updates pointers. This provides inherent crash consistency and enables snapshots, but can cause fragmentation and write amplification.

4. Explain fsync semantics

Detail that fsync forces a file's data and metadata to persistent storage, ensuring durability. Discuss that it doesn't guarantee ordering of writes to different files unless combined with other mechanisms, and note performance implications.

5. Compare and choose based on requirements

Summarize trade-offs: journaling is common for general-purpose file systems, COW is used in systems like ZFS and Btrfs for snapshots and integrity, and fsync is a tool for applications to enforce durability. Discuss how to combine them (e.g., journaling + fsync) for specific workloads.

Key Points to Mention

  • Journaling modes: writeback, ordered, and data journaling, and their different consistency guarantees.
  • Copy-on-write benefits: atomic updates, snapshots, and avoiding in-place overwrites; drawbacks: fragmentation and garbage collection overhead.
  • fsync guarantees: durability of a single file's data and metadata, but not atomicity across multiple files or directories.
  • The role of write barriers and disk caches in ensuring ordering and durability.
  • Trade-offs between performance (latency, throughput) and consistency (durability, atomicity).
  • Real-world examples: ext4 (journaling), ZFS/Btrfs (COW), and databases (e.g., SQLite) using fsync for durability.

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

Q5

How would you scale this file system design to a distributed setting, covering the metadata service, data servers, replication, and garbage collection?

System DesignData Modeling
Author's notes

Saved this for the end and we were running low on time, which hurt me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining the core components of a distributed file system: a scalable metadata service, data servers for storage, replication for fault tolerance, and garbage collection for space reclamation. Then discuss how to partition and replicate metadata, distribute data blocks, ensure consistency, and handle failures. Finally, address trade-offs and real-world examples like HDFS or GFS.

Pro tip: Emphasize the separation of metadata and data planes, and discuss how to handle metadata scalability (e.g., sharding, caching) and consistency (e.g., using Paxos/Raft). Mention that garbage collection should be asynchronous and consider reference counting or mark-and-sweep with leases.

1. Clarify requirements and assumptions

Ask about scale (number of files, size, read/write ratio), consistency needs, and fault tolerance. Assume a large-scale system like HDFS or GFS.

2. Design the metadata service

Propose a distributed metadata service using sharding (e.g., by namespace) and replication (e.g., via Raft) for high availability. Consider caching and hierarchical namespaces.

3. Design data servers and replication

Store file data in fixed-size blocks across data servers. Use replication (e.g., 3x) or erasure coding for durability. Discuss placement policies (rack awareness) and consistency models.

4. Address garbage collection

Implement asynchronous GC: track orphaned blocks via reference counting or mark-and-sweep. Use leases to avoid deleting blocks still in use. Consider delayed deletion for safety.

5. Discuss trade-offs and failure handling

Compare replication vs. erasure coding, strong vs. eventual consistency, and centralized vs. decentralized metadata. Explain how to handle node failures, network partitions, and rebalancing.

Key Points to Mention

  • Metadata sharding and replication (e.g., using Raft/Paxos) for scalability and fault tolerance.
  • Data placement and replication strategies (rack awareness, 3x replication, erasure coding).
  • Consistency models: strong consistency for metadata, eventual consistency for data.
  • Garbage collection mechanisms: reference counting, mark-and-sweep, leases, and delayed deletion.
  • Failure detection and recovery: heartbeats, block reports, and re-replication.
  • Real-world examples: HDFS, GFS, Colossus, and Databricks' Delta Lake.

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