Technical Design: Search + Sharding Trade-offs
Design a search service that lets users query documents/products with keywords.
Functional requirements
-
GET /search?q=...
returns top results ranked by relevance.
-
Support basic filtering (e.g., category, language, tenant/app id).
-
P95 latency target (e.g., < 200 ms) and ability to scale to large corpora.
Non-functional requirements
-
Data size grows to billions of docs.
-
Frequent reads, continuous ingestion/updates.
-
High availability.
Prompt
-
Describe how you would implement the core search algorithm at a high level (indexing + querying).
-
Propose a
sharding strategy
for the index.
-
Discuss trade-offs: latency, cost, rebalancing, hot keys, consistency, and operational complexity.
No need to write production code, but be concrete about components and data flows.