Katkat

Design a Top-K search words service

LinkedInSoftware Engineer · Technical Screen

Last updated

The question evaluates understanding of scalable, low-latency analytics and search-event systems, including high-throughput event ingestion, Top-K aggregation across all-time and sliding windows, normalization/deduplication trade-offs, and multi-region consistency considerations.

Scenario

Design a service that tracks user search queries and returns the Top-K most searched words/queries.

Requirements

Functional

  • API to record a search query event (e.g., user searches "iphone 16").
  • API to fetch Top-K queries.
  • Support a time window variant:
  • (a) all-time Top-K
  • (b) Top-K over the last N minutes/hours (trending)

Non-functional

  • High write QPS (search events), low latency reads for Top-K.
  • Scalable horizontally.
  • Reasonable correctness (define whether exact or approximate is acceptable).

Clarifications to address

  • What is a “word” vs “query” (full string)?
  • Case-folding, normalization, stop words, punctuation.
  • Deduping (e.g., multiple searches by same user) or count every event.
  • Multi-region and eventual consistency expectations.