Design a Windowed Hit Counter with Fixed Buckets and Concurrency

Read the full interview experience this question came from →

Quick Overview

Design a hit counter using per-second aggregation and timestamped ring buckets. Explain fixed-window complexity, stale-slot reuse, linearizable locking, and the extra contract needed for late events.

Design a Windowed Hit Counter with Fixed Buckets and Concurrency

Company: Nutanix

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

Design a hit counter and discuss three follow-ups: many hits at the same timestamp, reducing storage and operation cost with two fixed-size arrays, and thread safety with attention to contention. ### Constraints and Clarifications The source names problem362 but does not reproduce its window or boundary contract; its official statement is access-gated. For a self-contained design, choose integer-second timestamps, a fixed window W, nondecreasing operation timestamps, and queries counting hits in(t-W,t]. These are explicit practice assumptions, not imported numeric limits. Clarify whether concurrent callers use processing time or may submit late event timestamps. ### What a Strong Answer Covers Aggregate identical timestamps, store bucket timestamps and counts in a ring, explain stale-slot reuse, and state complexity in terms of W. Define a consistency model for concurrent hits and queries rather than assuming atomic increments alone are sufficient. ### Follow-up Questions - Why is O(W) scanning called constant time only when W is treated as a fixed configured constant? - What changes if events arrive out of order?

Overview: Design a hit counter using per-second aggregation and timestamped ring buckets. Explain fixed-window complexity, stale-slot reuse, linearizable locking, and the extra contract needed for late events.

Read the full Nutanix Software Engineer interview experience this question came from

Nutanix logo
Nutanix
Nov 2, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

Design a hit counter and discuss three follow-ups: many hits at the same timestamp, reducing storage and operation cost with two fixed-size arrays, and thread safety with attention to contention.

Constraints and Clarifications

The source names problem362 but does not reproduce its window or boundary contract; its official statement is access-gated. For a self-contained design, choose integer-second timestamps, a fixed window W, nondecreasing operation timestamps, and queries counting hits in(t-W,t]. These are explicit practice assumptions, not imported numeric limits. Clarify whether concurrent callers use processing time or may submit late event timestamps.

What a Strong Answer Covers Guidance

Aggregate identical timestamps, store bucket timestamps and counts in a ring, explain stale-slot reuse, and state complexity in terms of W. Define a consistency model for concurrent hits and queries rather than assuming atomic increments alone are sufficient.

Follow-up Questions Guidance

  • Why is O(W) scanning called constant time only when W is treated as a fixed configured constant?
  • What changes if events arrive out of order?