Versioned Query-DAG Result Cache
Design reusable intermediate query results without crossing input-version, operator or tenant boundaries.
Problem statement
For this exercise, assume an analytics service executes deterministic query DAGs over immutable, versioned input snapshots. Reuse a completed node result when another query asks for the same operator, parameters, input versions and permitted tenant context.
Compute misses normally, publish only complete reusable results, and evict or expire artifacts under a finite storage budget. A cache miss or cache outage must change performance, not the answer. New input snapshots and changed operator versions must not reuse incompatible old results.
Nondeterministic operators are bypassed unless their complete semantics can be captured in the key. Streaming state, query-optimizer implementation and cross-tenant result sharing are out of scope. This practice exercise is based on an interview-preparation compilation, not an independently dated interview occurrence.
What to build
- Look up and reuse a completed compatible DAG-node result, including its reusable intermediate dependencies.
- Compute misses through the normal engine and make a result reusable only after its artifact and metadata are complete.
- Prevent incompatible or cross-tenant reuse and enforce expiration/eviction within a finite cache budget while allowing correct uncached execution.
At scaleExercise target
- 100 queries per second, with up to 100 DAG nodes per query, create substantial repeated metadata lookups and occasional duplicate computations.
- Cached node artifacts range from 1 MB to 1 GB and share a 10 TB storage budget; eviction and transfer cost therefore matter.
- Metadata hit decisions take under 20 ms at the 95th percentile, excluding artifact transfer or recomputation; cache unavailability falls back to uncached execution.