← Databricks Interview Insights

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

SeniorPrefer not to say
Jun 2026

Summary

System design round at Databricks for an AI Engineer role. The whole thing was basically one big deep-dive into cache design, which sounds manageable until they start layering in hit counting with time windows and thread safety and suddenly you're juggling four different problems at once.

Questions Asked (1)

Q1

Design a key-value cache that supports get and put operations with optional TTL, an LRU eviction policy, and an efficient hit-count query that returns cache hits overall and per key within a recent time window.

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

I started with the hash map plus doubly linked list for LRU, which felt solid, but the hit-count-with-time-window part is where I fumbled.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and scale, then design the core data structures: a hash map for O(1) key lookup and a doubly linked list for LRU ordering, with TTL handled via lazy expiration or a min-heap. For hit-count queries, propose a sliding window approach using time-bucketed counters (e.g., per-minute buckets) to efficiently compute overall and per-key hits within a recent window. Discuss trade-offs between memory, accuracy, and complexity, and consider concurrency and eviction interactions.

Pro tip: Mention that TTL expiration should be lazy (on access) combined with periodic cleanup to avoid a background thread per key, and that hit-count windows can be approximated with bucketed counters to balance memory and precision—this shows you understand real-world caching systems like Redis.

1. Clarify Requirements and Scale

Ask about expected throughput, latency, memory constraints, and whether the cache is single-node or distributed. Confirm the definition of 'recent time window' (e.g., last 5 minutes) and whether exact or approximate hit counts are acceptable.

2. Design Core Data Structures

Propose a hash map for O(1) key lookup and a doubly linked list for LRU eviction. For TTL, discuss lazy expiration on get/put and a min-heap or timing wheel for proactive cleanup.

3. Implement Hit-Count Query

Use time-bucketed counters (e.g., per-second or per-minute) stored in a sliding window structure. Maintain overall and per-key counters, and aggregate buckets on query to return hits within the window.

4. Address Concurrency and Eviction

Discuss thread-safety using fine-grained locks or sharding, and ensure eviction respects TTL and updates hit counters correctly. Consider lock-free approaches or read-write locks for high concurrency.

5. Analyze Trade-offs and Optimizations

Compare exact vs. approximate hit counting, memory overhead of per-key buckets, and TTL cleanup strategies. Suggest optimizations like sampling, probabilistic data structures, or tiered storage if needed.

Key Points to Mention

  • O(1) get and put using hash map + doubly linked list for LRU
  • TTL handling: lazy expiration on access plus periodic cleanup (min-heap or timing wheel)
  • Sliding window hit counts using time-bucketed counters (e.g., per-minute buckets)
  • Trade-offs: exact vs. approximate counts, memory vs. accuracy, and cleanup overhead
  • Concurrency: sharding, fine-grained locks, or lock-free data structures
  • Eviction policy interaction with TTL and hit counters (e.g., evict expired items first)

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