You are designing a system to power the Top Trending Queries section on the home page of an AI search/Q&A platform (similar to Perplexity).
The product shows a list of trending user queries (search prompts) to visitors. Initially this list can be global, but over time you may want to personalize it (e.g., by country, language, or user interests).
Requirements and goals:
-
Continuously identify queries that are "trending" (rising in popularity) in near real time.
-
Rank top K trending queries for the
home page
.
-
Support:
-
Global trending queries.
-
Trending queries per region or segment (e.g., country, language, topic).
-
Eventually allow
personalization
: show trending queries that are more relevant to a specific user or user segment.
-
Handle very high query volume (e.g., tens of thousands of QPS).
-
Keep results fresh (updated within a few seconds to a few minutes).
Design task:
Describe how you would design this trending queries system, including:
-
How you collect and process raw query events.
-
How you define and compute "trending" (not just absolute popularity but spikes/velocity).
-
The data architecture for real-time or near-real-time aggregation (streaming vs batch).
-
How you store and serve the top K trending queries globally and by segment.
-
How you might add personalization over time (per user or per user group).
-
Key metrics, scaling considerations, and how to handle spam/abuse.
You do not need to provide code, but you should describe main components, data flows, and algorithms or approximations (e.g., for top-K) that you would use.