← Asana Interview Insights

Asana·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Jul 2026

Summary

Asana system design round for a software engineer role. The problem was a classic large-scale log processing question but with enough memory constraint twists that it kept me on my toes the whole time.

Questions Asked (1)

Q1

You have a log file that's too large to fit in memory, where each line is an IPv4 address. How would you find the most frequent IP address, or the top K most frequent, under strict memory constraints? Walk through your data structures, disk usage, and how your approach shifts as the file grows to hundreds of GB or if an approximate answer is acceptable.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

This one took me a minute to get my footing.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying constraints (exact vs approximate, memory limit, file size) and then present a scalable solution: external sort or hash-based partitioning to count frequencies, followed by a min-heap for top K. Discuss how the approach adapts for hundreds of GB (e.g., distributed processing) and when approximate answers are acceptable (e.g., Count-Min Sketch).

Pro tip: Always quantify memory usage and I/O trade-offs; mentioning specific numbers (e.g., '1 billion IPs ~ 4GB raw, but with hash map overhead ~ 20GB') shows practical experience. Also, consider using a disk-based hash table or embedded database like SQLite for simplicity.

1. Clarify requirements and constraints

Ask about exact vs approximate, memory limit, file size, and whether the file fits on disk. This determines the algorithm choice.

2. Choose a counting strategy

For exact counts, use external sort or hash partitioning to bring identical IPs together. For approximate, use Count-Min Sketch or Lossy Counting.

3. Implement top K selection

After counting, use a min-heap of size K to efficiently find the top K frequent IPs, or sort the counts if K is large.

4. Scale for hundreds of GB

If the file is too large for a single machine, use MapReduce or a distributed framework (e.g., Spark) to partition and count in parallel.

5. Discuss trade-offs and optimizations

Compare time vs memory vs accuracy. Mention compression, sampling, or streaming algorithms to handle constraints.

Key Points to Mention

  • External sorting: sort the file on disk, then scan to count consecutive identical IPs.
  • Hash partitioning: split the file into chunks by hash of IP, count each chunk in memory, then merge.
  • Min-heap for top K: maintain a heap of size K while counting to avoid storing all counts.
  • Count-Min Sketch: approximate frequency counting with sub-linear space, suitable for streaming data.
  • Distributed processing: use MapReduce/Spark for hundreds of GB, with map emitting (IP,1) and reduce summing counts.
  • Memory overhead: consider using a trie or compact hash map for IPv4 addresses to reduce memory footprint.

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