PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/System Design/Google

Scale median under memory constraints

Last updated: Mar 29, 2026

Quick Overview

This System Design question evaluates understanding of streaming data processing, quantile estimation, and the design of memory-constrained services that must trade off accuracy, latency, memory, and I/O.

  • hard
  • Google
  • System Design
  • Software Engineer

Scale median under memory constraints

Company: Google

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Onsite

Assume the two-heap streaming-median approach exceeds available memory for a very large or unbounded stream. Identify the bottlenecks and propose scalable designs to continue producing exact or approximate medians and the loose-median interval under memory constraints. Consider options such as external-memory algorithms, bucketization, quantile sketches, distributed aggregation, and windowed processing. Explain trade-offs in accuracy, latency, memory, and I/O, and outline failure handling and back-pressure strategies.

Quick Answer: This System Design question evaluates understanding of streaming data processing, quantile estimation, and the design of memory-constrained services that must trade off accuracy, latency, memory, and I/O.

Related Interview Questions

  • Design a Security Monitoring Framework - Google (medium)
  • Design an Online Coding Judge Platform - Google (medium)
  • Design Calendar Event Conflict Handling - Google (medium)
  • Design a pub-sub replay system - Google (hard)
  • How to host many domains on one IP? - Google (medium)
Google logo
Google
Aug 8, 2025, 12:00 AM
Software Engineer
Onsite
System Design
5
0

Design a Scalable Streaming Median Service Under Memory Constraints

Context

You are building a service that consumes a very large or unbounded stream of numeric values and must continuously report:

  • The median (exact if feasible, otherwise approximate), and
  • A "loose-median" interval: a value range [L, R] guaranteed to contain the true median.

The classic two-heap (max-heap for lower half, min-heap for upper half) approach requires storing all seen values and therefore exceeds memory when the stream is very large.

Tasks

  1. Identify the bottlenecks of the in-memory two-heap approach for very large/unbounded streams.
  2. Propose scalable designs that continue producing exact or approximate medians and the loose-median interval under memory constraints. Consider:
    • External-memory (disk-backed) algorithms
    • Bucketization/histograms
    • Quantile sketches (e.g., GK, KLL, t-digest)
    • Distributed aggregation
    • Windowed (e.g., sliding/tumbling) processing
  3. Explain the trade-offs across accuracy, latency, memory, and I/O for each option.
  4. Outline failure handling and back-pressure strategies suitable for a production service.

State any minimal assumptions you make (e.g., numeric domain, tolerance for approximation, latency SLOs).

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Google•More Software Engineer•Google Software Engineer•Google System Design•Software Engineer System Design
PracHub

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL 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.