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.
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.
- Clients
- Agents
- Entry
- Gateway
- Services
- Metrics service
- Downsampling workers
- Alert rules
- Queues, caches
- Ingest buffer
- Data, outside
- Time-series database
- Cold storage
1. Requirements and scope
- 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.
- 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).
2. Back-of-the-envelope numbers
- 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.
3. API
4. Data model and storage
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.
- The order of the steps
- A request or its reply
The parts: switch one off
1. Clients
2. Services
3. Data, outside
The steps in words0 of 3 steps shown
Agents to Metrics service
An agent posts cpu = 71% for host web-1.
Metrics service to Time-series database
The server inserts one row in PostgreSQL.
Metrics service to Agents
The agent gets "saved".
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
- Agent
- Gateway
- Time-series database
- Disk log
- Downsampling workers
- Object storage
Agent to Gateway
An agent on each server sends a batch of points every 10 seconds, such as cpu = 71% for host web-7.
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.
Time-series database to Disk log
The node appends the points to a log on disk, then to a compressed block in memory.
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
- Dashboard
- Gateway
- Time-series database
- Object storage
Dashboard to Gateway
A dashboard asks for average CPU over the last 30 days.
Gateway to Time-series database
The database picks the resolution. For 30 days it uses 1-hour points, not raw 10-second ones.
Time-series database to Object storage
It reads the older blocks from object storage and merges them with recent data.
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
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.
| What is judged | Junior | Mid | Senior | Staff |
|---|---|---|---|---|
| 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
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.
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
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.
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
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.
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
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.
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
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.
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.]