← Meta Interview Insights

Meta·Backend Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Apr 2026

Summary

Meta backend design round, one big question about building a top-K ranking system. The scope was wide enough that I kept second-guessing whether to go deeper on one area or keep moving. Felt okay coming out but there's a lot of surface area to cover in 45 minutes.

Questions Asked (1)

Q1

Design a system that returns the top-K items by a given metric in real time, such as most-clicked products or trending tags.

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

This one sprawls fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: define 'top-K', metric update frequency, acceptable staleness, and scale. Then propose a two-tier architecture: a fast in-memory layer (e.g., Redis sorted sets or a heap) for real-time queries and a durable batch layer (e.g., Kafka + Flink/Spark) for accurate aggregation and recovery. Discuss trade-offs between exactness and approximation (e.g., count-min sketch) and how to handle updates and queries efficiently.

Pro tip: Emphasize that real-time top-K often requires approximate algorithms and caching; showing awareness of the latency-accuracy trade-off and proposing a hybrid exact/approximate solution demonstrates senior-level thinking.

1. Clarify requirements and constraints

Ask about the metric's update rate, query latency SLA, K value, data volume, and whether approximate results are acceptable. This scopes the problem and guides design choices.

2. Design data ingestion and aggregation

Propose a streaming pipeline (e.g., Kafka) to ingest events and a stream processor (e.g., Flink) to maintain counts per item. Discuss windowing and state management for real-time updates.

3. Choose a real-time top-K data structure

Select an in-memory structure like a min-heap of size K or a sorted set (e.g., Redis ZSET) for efficient updates and queries. Explain how to handle concurrent updates and queries.

4. Address scalability and fault tolerance

Partition the data stream by item ID, use distributed caches, and replicate state for fault tolerance. Discuss how to merge partial top-K results from partitions.

5. Discuss trade-offs and optimizations

Compare exact vs. approximate algorithms (e.g., count-min sketch), caching strategies, and batch vs. streaming. Mention how to handle late data and ensure consistency.

Key Points to Mention

  • Use of in-memory data structures like heaps or Redis sorted sets for O(log K) updates and O(K) queries.
  • Stream processing frameworks (e.g., Kafka + Flink) for real-time aggregation and windowing.
  • Partitioning and merging partial top-K results for scalability.
  • Approximate algorithms (e.g., count-min sketch) when exactness is not required, trading accuracy for memory and speed.
  • Caching strategies and precomputation to meet low-latency SLAs.
  • Fault tolerance via replication and checkpointing, and handling of late/out-of-order events.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.