Design the search and trending topics features for a Twitter-like platform. Users can search tweets by keywords, hashtags, or usernames and see results ranked by relevance and recency. The trending topics section shows the most talked-about subjects in real time, segmented by country and city. The platform has 500 million tweets per day and 50,000 search queries per second.
In your 90-second answer, cover: - Tweet search architecture: how tweets are indexed and queried in near-real-time - Ranking strategy for search results (balancing relevance and recency) - Trending topics computation: how you detect trending subjects from the firehose of tweets - Geographic segmentation of trends (country-level and city-level)
Constraints: new tweets must be searchable within 10 seconds. Trending topics must update at least every 60 seconds. Search results must return in under 200ms.
How to approach it
- Hint 1
For near-real-time search, use an inverted index that is updated as tweets arrive. Elasticsearch is purpose-built for this, but understand the underlying data structure (term -> document list).
- Hint 2
Trending detection is not just counting hashtags -- it is about detecting velocity (rate of increase). A hashtag used 10,000 times/day is not trending if it is always at 10,000. A hashtag that jumps from 100 to 5,000 in an hour is.
- Hint 3
Geographic segmentation requires associating each tweet with a location. Use the user's profile location or device GPS, and maintain separate trend counters per region.
Ready to answer it out loud?
Record your answer in 1:30 and Preptile scores it 1–10 with specifics — what landed, what you skipped, and what to say next time.
Practising needs an invite code. Join the waitlist and we’ll send you one.