What the interviewer is scoring
A system design round is open-ended on purpose. "Design a service that stores and serves historical market data" has no single right answer, so the interviewer scores how you get to an answer: whether you pin down what is being built before drawing boxes, whether your numbers are in the right order of magnitude, whether you find the part that will break first, and whether you can say what you gave up for what you gained.
The objective of this lesson is a fixed sequence you can run on any prompt, with estimates attached to each step. Candidates who skip straight to "we'll use Kafka and a database" lose the round even when the boxes are reasonable, because nothing they said was tied to a requirement or a number.
The six steps
| Step | Output | Typical time in a 45-minute round |
|---|---|---|
| 1. Requirements | Functional list, non-functional targets (latency, throughput, durability, availability), what is out of scope | 5–8 min |
| 2. Estimates | Request rate, data volume per day and per year, bandwidth, peak-to-average ratio | 3–5 min |
| 3. API | The handful of calls clients make, with arguments and return shapes | 3–5 min |
| 4. Data model | Entities, keys, how data is partitioned and indexed | 5 min |
| 5. High-level design | Components and the path a write and a read take through them | 10 min |
| 6. Bottlenecks and trade-offs | The component that saturates first, how it fails, what you would change at 10× scale | 10 min |
The order matters because each step constrains the next. The access pattern from the API decides the partition key; the volume estimate decides whether one machine is enough; the latency target decides whether a cache or an in-memory design is needed at all.
Step 1: requirements, said out loud
Ask questions that change the design, not questions for their own sake:
- Who are the clients and what do they do most? Researchers scanning years of data for many symbols (throughput, sequential reads) are a different system from a trading engine that needs the latest quote (latency, point reads).
- What are the numbers? Symbols, message rate, history depth, concurrent users.
- What must never happen? Lost data, a wrong price served, stale data served as fresh. This sets durability and consistency.
- What is out of scope? Say it explicitly: "I will not design the exchange feed handler; I assume normalised messages arrive on a stream."
Write the non-functional targets as numbers: "p99 read latency under 100 ms for a one-day, one-symbol query", "no acknowledged write is lost", "99.9% monthly availability for reads". A number can be designed against; "fast and reliable" cannot.
Step 2: estimates
Back-of-envelope estimates use round numbers and powers of ten. The constants worth memorising:
| Quantity | Value |
|---|---|
| Seconds in a day | |
| Seconds in a US equity session (6.5 h) | |
| Trading days per year | |
| 1 KB, 1 MB, 1 GB, 1 TB | bytes (decimal is fine for estimates) |
| Main-memory read | about 100 ns |
| Same-datacentre round trip | about 0.5 ms |
| Sequential read from SSD | on the order of 1 GB/s |
Always state the peak, not only the average. Market data is bursty: the open and close and news events can run one to two orders of magnitude above the session average, and a system sized for the average falls over exactly when it matters.
Worked example
sizing a tick store
You are asked to store every normalised order-book message for US equities. Assume 1 billion messages per day, all arriving during the 6.5-hour session, each stored in a compact binary record of 40 bytes. Assume bursts run at about 20× the session average, columnar compression gives 4×, and storage is replicated 3 times. Estimate the average and peak message rate, ingest bandwidth, and storage per day and per year.
Show solutionHide solution
Rates. The session is s, so the average rate is
At 20× the peak is about messages/s; round up and design for 1 million messages/s.
Bandwidth. Average: MB/s. Peak: MB/s, which is Mbit/s. That fits comfortably on one 10 GbE link and one machine's write path, so ingest does not need to be sharded for bandwidth; it may still be replicated for availability.
Storage. Raw per day: bytes GB. Per year: GB TB raw. Compressed 4×: about TB per year. Replicated 3×: about TB of disk per year of history.
What the numbers tell you. Ten years is roughly 76 TB replicated: too much for one machine's disks but small for object storage, so the design is "append the day's data to a log during the session, write compressed columnar files partitioned by date and symbol after the close, serve reads from those files". The hard part is not storage volume; it is the read path for wide queries, which the next steps address.
Steps 3 and 4: API and data model
Keep the API to the calls that matter and make the arguments reveal the access pattern:
get_ticks(symbol, start_ts, end_ts) -> stream of messages
get_bars(symbols[], start_date, end_date, freq) -> table (symbol, ts, o, h, l, c, v)
get_snapshot(symbol, ts) -> order book at ts
Read the API back as a statement about the data model. get_ticks scans one symbol over a time range, so data should be physically sorted by (symbol, timestamp) within a partition. get_bars over many symbols and years is a large sequential scan, so a columnar layout (read only the columns asked for) and precomputed bars pay off. get_snapshot needs either a replay from the previous snapshot or periodic stored snapshots, which is a classic space-for-time trade.
A sensible partition key is (date, symbol): a day's ingest writes one set of partitions, a query for one symbol over a month touches about 21 partitions, and a backfill or correction for one day rewrites only that day.
Steps 5 and 6: design, then break it
Draw the write path (feed → append-only log → end-of-day compaction into columnar files → catalogue of partitions) and the read path (client → query service → catalogue → files, with a cache for hot bars). Then go looking for the bottleneck, in this order:
- The component that sees peak load first. Here, the ingest log at 1M messages/s during the open.
- The component with the largest fan-out. A "10 years of 1-minute bars for 5,000 symbols" query reads millions of rows from thousands of partitions.
- The component with no redundancy. A single catalogue database is a single point of failure for every read.
For each, say what happens under failure and what you would change at 10× scale. That discussion is where most of the marks are.
Worked example
is a bar store a big-data problem?
A researcher wants 1-minute bars for 5,000 symbols over 10 years. Each bar is stored as six 8-byte fields (timestamp, open, high, low, close, volume), with the symbol implied by the partition. There are 390 one-minute bars in a session. How large is the full dataset, and what does that imply for the design?
Show solutionHide solution
Bars: .
Bytes: , about 236 GB uncompressed.
One symbol-day is bytes, under 19 KB. Two conclusions follow:
- The whole bar history fits on a single large SSD and could be scanned at around 1 GB/s in a few minutes. It is not a distributed-computing problem; one well-organised machine, or a columnar file store, serves it.
- Partitioning bars by
(date, symbol)would create million files of 19 KB each, which is terrible for any file system or object store. For bars, partition coarser, for example one file per symbol per year or one file per day holding all symbols. The right partition size depends on the data, and the estimate is what tells you.
Saying "236 GB, so it fits on one box" in an interview is worth more than any amount of distributed architecture, because it shows you sized the problem before solving it.
Knowledge check
A service receives 200 million requests per day, evenly spread over 24 hours, with peaks at 5 times the average. Roughly what peak request rate should you design for?
Knowledge check
Your design's main API call is 'get all ticks for one symbol between two timestamps'. Which physical layout serves it best?
Knowledge check
Which of these is a non-functional requirement stated in a form you can design against?
Key takeaways
- Run the same sequence every time: requirements, estimates, API, data model, high-level design, bottlenecks and trade-offs.
- Turn every non-functional requirement into a number with a percentile and a load.
- Estimate with round numbers and always size for the peak; market data bursts well above its average.
- Let the API's access pattern choose the partition key and sort order.
- Use estimates to decide what is hard: 40 GB a day of ticks and 236 GB of bars are storage problems a single well-designed system handles; the interesting work is the read path and failure handling.
Finished reading?
Answer the 3 knowledge checks to complete this lesson (0 done).