Add Sliding-Window Get and Put Activity Metrics to a Key-Value Store

Quick Overview

Extend an in-memory key-value store with `averageGet(window)` and `averagePut(window)` activity metrics for sliding windows of one hour, one day, and one week. Make the API or object boundaries explicit, then cover invariants, edge cases, testing strategy, and operational trade-offs.

Add Sliding-Window Get and Put Activity Metrics to a Key-Value Store

Company: Databricks

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

# Add Sliding-Window Get and Put Activity Metrics to a Key-Value Store Extend an in-memory key-value store with `averageGet(window)` and `averagePut(window)` activity metrics for sliding windows of one hour, one day, and one week. In this practice contract, each metric is the average operation rate over the full requested window: the number of completed operations of that type whose completion timestamps lie in `(now - window, now]`, divided by the window length in seconds. Do not measure operation latency. Avoid rescanning all history on every query. ### Constraints & Assumptions - Timestamps are monotonic and windows use operation completion time. - Supported window lengths are exactly `3600`, `86400`, and `604800` seconds. - Metrics must not change key-value correctness. ### Clarifying Questions to Ask - Is the intended meaning of “average” a full-window request rate, as defined here, or another source-provided denominator? - Must metrics survive restart? ### What a Strong Answer Covers - Timestamped get/put counts, eviction, concurrency, and memory bounds. - Clear behavior at window boundaries and under idle periods. ### Follow-up Questions - How would approximate buckets reduce memory? - How would you expose peak rates without confusing them with the requested average?

Quick Answer: Extend an in-memory key-value store with `averageGet(window)` and `averagePut(window)` activity metrics for sliding windows of one hour, one day, and one week. Make the API or object boundaries explicit, then cover invariants, edge cases, testing strategy, and operational trade-offs.

|Home/Software Engineering Fundamentals/Databricks
Databricks logo
Databricks
Jul 30, 2026, 12:00 AM
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

Add Sliding-Window Get and Put Activity Metrics to a Key-Value Store

Extend an in-memory key-value store with averageGet(window) and averagePut(window) activity metrics for sliding windows of one hour, one day, and one week. In this practice contract, each metric is the average operation rate over the full requested window: the number of completed operations of that type whose completion timestamps lie in (now - window, now], divided by the window length in seconds. Do not measure operation latency. Avoid rescanning all history on every query.

Constraints & Assumptions

  • Timestamps are monotonic and windows use operation completion time.
  • Supported window lengths are exactly 3600 , 86400 , and 604800 seconds.
  • Metrics must not change key-value correctness.

Clarifying Questions to Ask Guidance

  • Is the intended meaning of “average” a full-window request rate, as defined here, or another source-provided denominator?
  • Must metrics survive restart?

What a Strong Answer Covers Guidance

  • Timestamped get/put counts, eviction, concurrency, and memory bounds.
  • Clear behavior at window boundaries and under idle periods.

Follow-up Questions Guidance

  • How would approximate buckets reduce memory?
  • How would you expose peak rates without confusing them with the requested average?
Loading comments...