PracHub
QuestionsLearningGuidesInterview Prep
|Home/System Design/Google

Scale median under memory constraints

Last updated: Jun 24, 2026

Quick Overview

This interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Scale median under memory constraints states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

  • 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 interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Scale median under memory constraints states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

Related Interview Questions

  • Match Tagged Problems to Skilled Programmers at Scale - Google (medium)
  • Design a Task Scheduler for Opaque Long-Running GPU Jobs ("Design Sora") - Google (hard)
  • Design A Drive-Style Usage Quota Limiter - Google (medium)
  • Design a Security Monitoring Framework - Google (medium)
  • Design an Online Coding Judge Platform - Google (medium)
|Home/System Design/Google

Scale median under memory constraints

Google logo
Google
Aug 8, 2025, 12:00 AM
hardSoftware EngineerOnsiteSystem Design
8
0

Scale median under memory constraints

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).

Constraints & Assumptions

  • Preserve the scope, facts, inputs, and requested outputs from the prompt above.
  • If the prompt leaves a detail unspecified, state a reasonable assumption before relying on it.
  • Keep the answer interview-ready: concise enough to present, but concrete enough to implement or evaluate.

Clarifying Questions to Ask Guidance

  • Clarify users, core use cases, read/write patterns, scale, latency, availability, and data retention.
  • State explicit assumptions before making sizing or architecture decisions.
  • Prioritize the functional path first, then address reliability, security, observability, and rollout.

What a Strong Answer Covers Guidance

  • A scoped requirements summary with concrete non-goals and success metrics.
  • API, data model, architecture, consistency, capacity, and operations.
  • Reasoned trade-offs among simple and scalable designs, including bottlenecks and failure modes.
  • A validation, monitoring, migration, and launch plan appropriate for the risk level.

Follow-up Questions Guidance

  • What breaks first at 10x traffic or data volume?
  • How would you degrade gracefully during dependency failures?
  • What metrics and alerts would prove the design is healthy after launch?

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

Your design canvas — auto-saved

PracHub

Master your tech interviews with 9,000+ 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.