Problem
Design a platform that stores stock prices over time and can be queried later.
Core functionalities
-
Ingest price
: The system receives events of the form:
-
ticker
(string, e.g.,
AAPL
)
-
price
(decimal)
-
timestamp
(event time)
-
Query price
: Given a
ticker
and a
timestamp
, return the price for that ticker at that time.
Clarifications to address in your design (state assumptions)
-
If there is
no price exactly at that timestamp
, should the system return:
-
the most recent price
at or before
the timestamp (common), or
-
“not found” unless there is an exact match?
-
Expected scale: number of tickers, events/sec, retention (e.g., 1 day vs 10 years).
-
Latency targets for reads/writes.
-
Handling out-of-order events, duplicates, and clock skew.
Deliverables
-
High-level architecture (write path + read path).
-
Data model and storage choice.
-
APIs.
-
Partitioning/indexing strategy.
-
Consistency, availability, and failure-handling tradeoffs.