PracHub
QuestionsLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Meta

Design a Concurrent, Memory-Bounded Tally Service

Last updated: Jul 22, 2026

Quick Overview

Design a tally service that records timestamped events and answers inclusive range-count queries, beginning with an exact baseline and evolving toward high concurrency and bounded memory. Discuss retention and accuracy contracts, late events, contention, query performance, overflow, clock assumptions, and durability without assuming infinite exact history.

  • medium
  • Meta
  • Software Engineering Fundamentals
  • Software Engineer

Design a Concurrent, Memory-Bounded Tally Service

Company: Meta

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

# Design a Concurrent, Memory-Bounded Tally Service Design and implement the core of a `TallyService` with two operations: - `bump(timestamp)`: record one event at the given timestamp. - `query(start_time, end_time)`: return the number of recorded events whose timestamps lie in the inclusive range `[start_time, end_time]`. Begin with an exact in-memory design, then adapt it for high concurrency and bounded memory. If bounded memory requires retention or time-bucket approximation, make that contract explicit. Explain how bucket size affects accuracy and how queries remain fast. ### Constraints & Assumptions - Timestamps use one monotonic unit but calls can arrive concurrently and slightly out of order. - The service must define behavior for queries outside its retention window. - Counter overflow, clock source, and acceptable approximation must be clarified. - A process-local design is sufficient for the base problem; discuss durability as a follow-up. ### Clarifying Questions to Ask - Must every arbitrary range be exact, or may boundary buckets be approximate? - What retention horizon and timestamp resolution are required? - How late can events arrive, and can future timestamps occur? - What are the expected read-to-write ratio and contention level? ### What a Strong Answer Covers - A correct exact baseline and its time/space costs - An explicit impossibility trade-off between finite memory, infinite history, exact timestamps, and arbitrary queries - Thread-safe bucket rotation and counter updates - Prefix, tree, or hierarchical aggregation for faster queries - Boundary semantics, late events, overflow, and testing ### Follow-up Questions - How would you shard the service across machines? - How would you make bumps durable and idempotent? - Can a ring buffer be reset safely while another thread increments it? - What structure supports many queries at multiple time resolutions?

Quick Answer: Design a tally service that records timestamped events and answers inclusive range-count queries, beginning with an exact baseline and evolving toward high concurrency and bounded memory. Discuss retention and accuracy contracts, late events, contention, query performance, overflow, clock assumptions, and durability without assuming infinite exact history.

Related Interview Questions

  • Troubleshoot a production server outage - Meta (medium)
  • Troubleshoot a Midnight Web Server Outage - Meta (medium)
  • Design an Expected O(1) Randomized Container - Meta (medium)
  • Design a Trade Ledger Class - Meta (easy)
|Home/Software Engineering Fundamentals/Meta

Design a Concurrent, Memory-Bounded Tally Service

Meta logo
Meta
Jul 1, 2026, 12:00 AM
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
0
0

Design a Concurrent, Memory-Bounded Tally Service

Design and implement the core of a TallyService with two operations:

  • bump(timestamp) : record one event at the given timestamp.
  • query(start_time, end_time) : return the number of recorded events whose timestamps lie in the inclusive range [start_time, end_time] .

Begin with an exact in-memory design, then adapt it for high concurrency and bounded memory. If bounded memory requires retention or time-bucket approximation, make that contract explicit. Explain how bucket size affects accuracy and how queries remain fast.

Constraints & Assumptions

  • Timestamps use one monotonic unit but calls can arrive concurrently and slightly out of order.
  • The service must define behavior for queries outside its retention window.
  • Counter overflow, clock source, and acceptable approximation must be clarified.
  • A process-local design is sufficient for the base problem; discuss durability as a follow-up.

Clarifying Questions to Ask Guidance

  • Must every arbitrary range be exact, or may boundary buckets be approximate?
  • What retention horizon and timestamp resolution are required?
  • How late can events arrive, and can future timestamps occur?
  • What are the expected read-to-write ratio and contention level?

What a Strong Answer Covers Guidance

  • A correct exact baseline and its time/space costs
  • An explicit impossibility trade-off between finite memory, infinite history, exact timestamps, and arbitrary queries
  • Thread-safe bucket rotation and counter updates
  • Prefix, tree, or hierarchical aggregation for faster queries
  • Boundary semantics, late events, overflow, and testing

Follow-up Questions Guidance

  • How would you shard the service across machines?
  • How would you make bumps durable and idempotent?
  • Can a ring buffer be reset safely while another thread increments it?
  • What structure supports many queries at multiple time resolutions?
Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Meta•More Software Engineer•Meta Software Engineer•Meta Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.