Asked at
URL Shortener (TinyURL)
Asked from Junior level upFoundations & Storage
Distributed Rate Limiter
Asked from Mid level upAPI Gateway & Security
Distributed Key-Value Store
Asked from Senior level upFoundations & Storage
Distributed Notification Service
Asked from Mid level upMessaging & Queues
Distributed Web Crawler
Asked from Mid level upDistributed Systems
Metrics & Monitoring Platform
Asked from Senior level upObservability & Time-Series
Real-Time Chat App (like WhatsApp or Slack)
Asked from Mid level upReal-Time & WebSockets
Social News Feed (like X/Twitter)
Asked from Mid level upSocial & Feed Systems
Ride-Hailing App (like Uber)
Asked from Senior level upGeospatial & Real-Time
Low-Latency Stock Exchange Matching Engine
Asked from Staff level upFintech & Low Latency
Global Video Streaming Platform (like YouTube or Netflix)
Asked from Senior level upMedia & Streaming
Distributed Hotel & Ticket Reservation System
Asked from Mid level upE-Commerce & Transactions
Shared Document Editor (like Google Docs)
Asked from Staff level upReal-Time & Distributed State
Game Leaderboard
Asked from Junior level upCaching & Data Structures
File Sync Service (Dropbox / Google Drive)
Asked from Mid level upStorage
Payment System
Asked from Senior level upPayments & Transactions
Ad Click Aggregation
Asked from Senior level upStream Processing
AI Support Assistant (RAG)
Asked from Senior level upAI Systems
LLM Inference Platform
Asked from Senior level upAI Systems
Enterprise Semantic Search
Asked from Mid level upAI Systems
AI Code Completion
Asked from Senior level upAI Systems
LLM Gateway
Asked from Senior level upAI Systems
AI Agent That Takes Actions
Asked from Senior level upAI Systems
LLM Evaluation Platform
Asked from Senior level upAI Systems
AI Document Processing Pipeline
Asked from Mid level upAI Systems

Design a Metrics & Monitoring Platform

Asked from Senior level upDomain: Observability & Time-Series
Concepts to know first:

Design a system that collects numbers from many servers over time, sums them up, stores them, and answers questions about them. It handles billions of data points.

An analogy

Think of a metrics platform like the dashboard gauges in an airplane. Sensors continuously record altitude, engine heat, and fuel level every second, so pilots can spot warning lights before any engine stalls.

Where this design ends up. This is version 3 of 3. Part 5 builds it up from version 1 and says why each part was added.
  1. Clients
    • Agents
  2. Entry
    • Gateway
  3. Services
    • Metrics service
    • Downsampling workers
    • Alert rules
  4. Queues, caches
    • Ingest buffer
  5. Data, outside
    • Time-series database
    • Cold storage

1. Requirements and scope

Functional Requirements
  • Ingest metrics from millions of servers (counter, gauge, histogram).
  • Query metrics over customizable time windows (e.g. last 1 hour, last 30 days).
  • Trigger alert notifications when thresholds exceed SLA.
Non-Functional Requirements & SLAs
  • High write throughput (millions of metrics/sec).
  • Fast dashboard query latency (< 500ms).
  • Data retention with progressive downsampling (10s raw for 7 days, 1m for 30 days, 1h for 1 year).
Key Traffic Assumptions: 10,000 host nodes × 100 metrics each = 1,000,000 metrics reported every 10 seconds (100,000 QPS).

2. Back-of-the-envelope numbers

Writes and reads each second
  • Writes: 100,000 data points a second (99%)
  • Reads: 50 dashboard queries a second (1%)

Write-heavy: about 2,000 writes for each read. A queue and a store that is fast at writes help most here.

Write Throughput
100,000 data points/sec
Read Throughput
50 dashboard queries/sec
Storage Growth
100k/s × 16 bytes × 86,400 s × 365 ≈ 50 TB/year uncompressed; ~4.2 TB with Gorilla compression (~12x)
RAM Cache Footprint
64 GB RAM for recent in-memory time-series blocks

3. API

POST/api/v1/metrics/ingestBatch ingest: [{ metricName, timestamp, value, tags: { host, env } }]
GET/api/v1/metrics/queryQuery range: ?metric=cpu_idle&from=X&to=Y&step=1m

4. Data model and storage

Storage Strategy: A database built for numbers over time, such as Prometheus, InfluxDB or ClickHouse. It packs the data small with Gorilla compression.
Metric: metric_id (UUID), timestamp (uint64), value (float64), labels (JSONB/Tag index)

5. The design, in three versions

Version 1: Relational Time-Series Table

PostgreSQL table with composite index on (metric_name, timestamp).

Metrics & Monitoring Platform: Version 1: Relational Time-Series Table Version 1 of 3

The picture follows one request through the parts of this version, in order. Under it, switch a part off to see what the request does without it.

One request, step by step

Each numbered arrow is one step. Press "Simulate Request Flow" to follow them one at a time.

AgentsMetrics serviceTime-series database123
  • The order of the steps
  • A request or its reply

The parts: switch one off

1. Clients

Agentssend numbers every 10 s

2. Services

Metrics servicetakes in the points

3. Data, outside

Time-series databasepoints ordered by time

The steps in words0 of 3 steps shown

  1. Agents to Metrics serviceHTTPS · 3 ms

    An agent posts cpu = 71% for host web-1.

  2. Metrics service to Time-series databasequery · 8 ms

    The server inserts one row in PostgreSQL.

  3. Metrics service to Agentsreply · 20 ms

    The agent gets "saved".

Why this version
Simplest initial setup.
Next bottleneck
At 100,000 points a second the table grows by billions of rows a day. Index updates and deletes of old data soon overload one database.

Write path, read path and failures

Each path follows one request through the final design (version 3), one hop at a time.

Write pathIngest a data point

  1. Agent
  2. Gateway
  3. Time-series database
  4. Disk log
  5. Downsampling workers
  6. Object storage
  1. Agent to Gateway

    An agent on each server sends a batch of points every 10 seconds, such as cpu = 71% for host web-7.

  2. Gateway to Time-series database

    The gateway rejects tags with no limit on their values, such as user ids. It routes each series to its storage node.

  3. Time-series database to Disk log

    The node appends the points to a log on disk, then to a compressed block in memory.

  4. Downsampling workers to Object storage

    Later, background workers roll 10-second points up into 1-minute and 1-hour points. Old blocks move to cheap object storage.

Read pathDraw a dashboard

  1. Dashboard
  2. Gateway
  3. Time-series database
  4. Object storage
  1. Dashboard to Gateway

    A dashboard asks for average CPU over the last 30 days.

  2. Gateway to Time-series database

    The database picks the resolution. For 30 days it uses 1-hour points, not raw 10-second ones.

  3. Time-series database to Object storage

    It reads the older blocks from object storage and merges them with recent data.

  4. Time-series database to Dashboard

    It returns about 720 points instead of 259,200, so the chart draws in under 500 ms.

What breaks, and what happens then

  • A storage node is down

    What users see
    Its series cannot be written or read.
    What the design does
    Each series is written to two nodes. Agents also buffer a few minutes of points and send them again.
  • A burst of new tag values arrives

    What users see
    Memory fills with millions of tiny series, and queries slow down.
    What the design does
    The gateway caps the number of series per metric and rejects tags outside an allowed list.
  • The alerting service is down

    What users see
    No one is told about a real outage.
    What the design does
    Run two alert evaluators. A separate, very small check alerts when the monitoring system itself stops reporting.

6. Deep dives

Gorilla Time-Series Compression
Times are stored as the change in the gap between points. When points arrive at a steady pace, that change is 0, which takes only 1 bit. Each value is stored as its XOR with the value before, which is small when values change little.

7. Follow-up questions

  • How do you solve high cardinality tag explosion? (Answer: Enforce strict tag whitelisting at gateway and reject unbounded dynamic values like userIds or UUIDs).

What it costs

Storage of raw points is the bill: about 50 TB a year before compression, about 4.2 TB after. Keeping every point for ever is the common mistake. Keep recent data in full, and keep only averages for old data.

Another way to design it

Agents can push their numbers, as here, or the platform can pull them from each server on a timer, as Prometheus does. Pulling makes a dead server easy to spot. Pushing suits short jobs and servers behind a firewall.

8. How answers are judged

A passing answer at Mid level. A complete design with numbers: about 100,000 metric points a second. It stores points as a time series per metric and goes deep on one part, such as compression or storage.

How each level is judged
What is judgedJuniorMidSeniorStaff
BreadthHow much of the system does the answer cover?Names the core parts: clients, servers, a database and a cache.Covers the whole main flow, from the request to the stored data and back.Builds a complete design without being led through it.Covers the system, the systems around it and who owns each part.
DepthHow far does it go into the hard parts?Explains what each part does and why it is there.Goes deep on one part, such as the database or the cache.Goes deep on the two or three riskiest parts.Goes deepest where the risk is largest, and explains why the risk is there.
DrivingWho leads the conversation?Follows the interviewer, step by step.Moves forward alone, with an occasional nudge.Leads the conversation from start to finish.Changes the problem when the question asked is not the right one.
Trade-offsAre choices compared and justified?Names more than one option.Says why one option was picked over another.Compares options in detail, with what each one costs.Ties each choice to cost, speed and risk for the business.
Unclear questionsWhat happens when the question is vague?Answers the questions that are asked.Asks questions to make the problem clear.Sets the scope and says what is left out.Questions the assumptions behind the problem itself.
ScopeWhat does it consider beyond the normal path?Covers the normal path, when everything works.Adds what happens when a part fails.Adds growth: what breaks at ten times the load, and the fix.Adds abuse, cost and the daily work of running the system.

Requirements and scope

Strong answer
Before I design, I want to check the scope. Servers report counters, gauges and histograms, and dashboards query a chosen time range. Since writes come from thousands of hosts but dashboard queries are rare, I will design ingestion for far higher throughput than queries.
Weak answer
Servers push metric points constantly, and dashboards read them back to draw charts. Since both happen often, I will split my design time evenly between the write path and the query path.

Shows: Unclear questionsThe difference: Writes run at about 100,000 a second while dashboard queries run at about 50 a second, a ratio of 2,000 to 1. The weak answer never asks about that gap.

Estimates

Strong answer
10,000 hosts each reporting 100 metrics every 10 seconds is 1,000,000 points every 10 seconds, or 100,000 a second. At 16 bytes a point, a year of raw data is about 50 TB, which Gorilla compression cuts to about 4 TB.
Weak answer
10,000 hosts reporting once every 10 seconds is about 1,000 points a second, so I will design the ingestion path for that rate.

Shows: DepthThe difference: The weak answer skips the 100 metrics per host, undercounting the true rate by 100 times. The real rate is 100,000 points a second.

Core design

Strong answer
Agents push points to a gateway, which writes them through Kafka into time-series storage keyed by metric name, timestamp and labels. Each point is written once and read back as a range for one metric, so storage is built around ordered time ranges, not single-row lookups.
Weak answer
I would store each point as a row in a relational table, indexed on metric name and timestamp. That is the same way I would store any other event log.

Shows: DepthThe difference: At 100,000 points a second, about 8.6 billion rows a day, one indexed table struggles with inserts, index upkeep and storage. Time-series storage appends and compresses points instead.

Deep dive

Strong answer
The hard part is cardinality. Every distinct combination of labels creates a separate time series, and a label like a user ID can create millions of them, exhausting the index. I would enforce a fixed set of allowed label names at the gateway, and reject unbounded values, such as a raw user ID.
Weak answer
I would let services attach whatever labels they find useful, such as user ID or request ID. More labels make it easier to filter and debug later.

Shows: DepthThe difference: A label with unbounded values, like a user ID, creates a new time series per value, exhausting the index. The strong answer limits labels to a fixed set.

Failures and trade-offs

Strong answer
If ingestion falls behind, a Kafka buffer absorbs the burst so agents are not blocked. If the backlog keeps growing, I would apply backpressure to low-priority agents and page on-call once consumer lag passes a threshold.
Weak answer
If ingestion falls behind during a burst, I would let it queue up in Kafka. The consumers will work through the backlog once the burst ends.

Shows: ScopeThe difference: Assuming the backlog clears on its own misses that a stuck consumer never catches up, and nobody is alerted. The strong answer watches lag and sheds load instead.

We wrote this guide in our own words, informed by public interview guides such as AlgoMaster and Hello Interview. We are not connected to either site. Interviewers differ. The guide and the example answers show the direction each level takes, not a checklist.

10. Check your design with your own AI

Write your design first. Then copy this prompt into the AI chat you already use, and add your design at the end. It asks for a score in each area, one fix for each, and two follow-up questions.

The site sends nothing anywhere. An AI review can be wrong, so check what it says against sections 8 and 9.

See the prompt
You are a system design interviewer. Review my design for the interview problem below.

Problem: Design a Metrics & Monitoring Platform
Design a system that collects numbers from many servers over time, sums them up, stores them, and answers questions about them. It handles billions of data points.

What users must be able to do:
- Ingest metrics from millions of servers (counter, gauge, histogram).
- Query metrics over customizable time windows (e.g. last 1 hour, last 30 days).
- Trigger alert notifications when thresholds exceed SLA.

How well it must work:
- High write throughput (millions of metrics/sec).
- Fast dashboard query latency (< 500ms).
- Data retention with progressive downsampling (10s raw for 7 days, 1m for 30 days, 1h for 1 year).

Numbers to assume:
- 10,000 host nodes × 100 metrics each = 1,000,000 metrics reported every 10 seconds (100,000 QPS).

Judge my design at the Mid level.
A passing answer at this level: A complete design with numbers: about 100,000 metric points a second. It stores points as a time series per metric and goes deep on one part, such as compression or storage.

For each area below, say whether my design is strong, fine or weak. Give one reason and one fix for each:
1. Requirements and scope
2. Estimates
3. Core design
4. Deep dive
5. Failures and trade-offs

Then ask me the two follow-up questions an interviewer would ask next.
Do not write a full model answer for me.

My design:
[Describe your parts, how one request moves through them, and why you chose each one.]