← Pinterest Interview Insights

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

Senior
May 2026

Summary

Pinterest system design round for a software engineer role, focused entirely on building an autocomplete service from scratch. Pretty deep dive, they wanted the full picture from data ingestion to ranking to trade-offs.

Questions Asked (4)

Q1

Design an autocomplete/input-suggestion service for a search engine that returns the top-K completions as a user types, with support for typo tolerance and personalization.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

This question is deceptively wide.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (scale, latency, personalization, typo tolerance) and then design a multi-tier system: a fast in-memory trie or finite-state transducer for prefix matching, a ranking layer that blends popularity and personalization signals, and a typo-tolerance mechanism using edit distance or n-gram indexes. Discuss trade-offs between latency, accuracy, and cost, and propose a scalable architecture with caching and sharding.

Pro tip: Emphasize the importance of offline vs online computation: precompute top-K suggestions for popular prefixes offline and serve them from a cache, while handling long-tail prefixes and typos with a fallback online algorithm. This shows you understand real-world latency constraints.

1. Clarify Requirements and Constraints

Ask about scale (QPS, number of users), latency SLA (e.g., <100ms), data freshness, personalization depth, and typo tolerance expectations. This sets the scope and guides design decisions.

2. Design Data Structures for Prefix Matching

Propose a trie or finite-state transducer (FST) for efficient prefix lookup, storing top-K suggestions per node. Discuss memory optimization and sharding for large vocabularies.

3. Incorporate Ranking and Personalization

Explain how to rank suggestions using signals like query popularity, recency, user history, and context. Describe a two-stage ranking: retrieve candidates from the trie, then re-rank with a lightweight model.

4. Add Typo Tolerance

Use edit distance (e.g., Levenshtein automaton) or n-gram indexes to find close matches. Discuss trade-offs between accuracy and latency, and how to merge typo-corrected results with prefix matches.

5. Architecture and Scaling

Outline a distributed system: offline pipeline to build and update the index, online serving layer with caching (e.g., Redis), and sharding by prefix. Address consistency, fault tolerance, and monitoring.

Key Points to Mention

  • Trie or FST for efficient prefix matching with top-K stored at nodes
  • Offline precomputation of popular prefixes and caching for low latency
  • Personalization via user history and context, with privacy considerations
  • Typo tolerance using edit distance or n-gram indexes
  • Ranking signals: popularity, recency, user engagement, and business rules
  • Sharding, replication, and load balancing for scalability and fault tolerance

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

Q2

How would you handle the data pipeline that keeps autocomplete suggestions fresh, especially for trending queries?

System DesignData Modeling
Author's notes

I talked about a streaming ingestion layer reading from query logs and updating per-prefix counts, plus a periodic batch rebuild for correctness.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: scale (queries per second, number of users), latency targets, and freshness needs (e.g., trending queries should appear within minutes). Then propose a hybrid architecture that combines batch processing for stable suggestions with a streaming pipeline for real-time trending queries, and discuss trade-offs between latency, cost, and complexity.

Pro tip: Emphasize the importance of a feedback loop: monitor click-through rates and query success metrics to continuously improve ranking, and use A/B testing to validate changes. This shows you think beyond just data freshness to business impact.

1. Clarify Requirements

Ask about scale (QPS, data volume), latency requirements (how fresh?), and what 'trending' means (time window, velocity). This ensures your design meets actual needs.

2. High-Level Architecture

Propose a lambda architecture: a batch layer (e.g., Hadoop/Spark) for comprehensive suggestions and a speed layer (e.g., Kafka + Flink/Spark Streaming) for real-time trending queries. Serve via a fast lookup store like Redis or Cassandra.

3. Data Collection & Processing

Detail how to ingest user queries (e.g., via Kafka), aggregate counts in sliding windows (e.g., 1 min, 5 min, 1 hour), and compute trending scores (e.g., using exponential decay or z-score). Handle late data and ensure exactly-once semantics.

4. Serving & Ranking

Explain how to merge batch and real-time results, rank suggestions (e.g., by popularity, personalization, or diversity), and serve with low latency. Use caching and precomputation for hot queries.

5. Monitoring & Iteration

Discuss monitoring freshness (e.g., lag metrics), quality (CTR), and system health. Plan for A/B testing and continuous improvement.

Key Points to Mention

  • Lambda architecture (batch + speed layer) for balancing freshness and completeness
  • Stream processing with windowing (tumbling, sliding) and handling out-of-order events
  • Trending detection algorithms (e.g., time-decayed counts, z-score, or moving averages)
  • Storage choices: Redis for low-latency serving, Cassandra for scalability, and Kafka for ingestion
  • Personalization and ranking factors (user history, location, diversity) to improve relevance
  • Monitoring and feedback loops (CTR, latency, freshness SLAs) for continuous improvement

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

Q3

Walk through your ranking approach: how do you balance query frequency, recency, and personalization signals like user history and location?

System DesignTechnical Trade-offs
Author's notes

Went with time-decayed frequency as the base score, then layered in user history and location as re-ranking signals.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the ranking problem as a multi-objective optimization where you combine signals into a single score, then explain how you'd weight and normalize each signal based on business goals and user context. Walk through a concrete example (e.g., Pinterest home feed) to show how you'd balance frequency, recency, and personalization, and discuss trade-offs like exploration vs exploitation and cold-start users.

Pro tip: Emphasize that ranking is iterative: you'd start with a simple heuristic (e.g., weighted sum) and then move to machine learning models once you have enough data, but always maintain interpretability and fallbacks for new users.

1. Define objectives and constraints

Clarify what you're optimizing for (e.g., engagement, relevance, diversity) and any constraints (latency, fairness, freshness). This sets the context for balancing signals.

2. Identify and normalize signals

List key signals: query frequency (how often a pin is queried), recency (time since pin creation or last interaction), user history (past clicks, saves), and location. Normalize each to a common scale (e.g., 0-1) to combine them.

3. Design scoring function

Propose a weighted sum or a learned model (e.g., logistic regression, GBDT) that combines signals. Explain how weights are determined (e.g., via A/B testing, offline evaluation) and how to handle interactions (e.g., recency might matter more for news, less for evergreen content).

4. Incorporate personalization and context

Describe how user history and location modify the base score: e.g., boost items from followed users or nearby locations, or use collaborative filtering. Mention cold-start strategies like using global trends or demographic-based defaults.

5. Evaluate and iterate

Explain how you'd measure success (online metrics like CTR, saves; offline metrics like NDCG) and iterate on weights or model features. Highlight trade-offs like freshness vs relevance and the need for exploration.

Key Points to Mention

  • Normalization of signals to avoid scale bias (e.g., min-max scaling, z-score).
  • Weighting strategies: manual tuning vs learning-to-rank models.
  • Handling cold-start users with location or global popularity.
  • Trade-offs between recency and long-term relevance (e.g., time decay functions).
  • Use of A/B testing to validate ranking changes and avoid regressions.
  • Exploration vs exploitation: injecting diversity to prevent filter bubbles.

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

Q4

How would you shard and scale the in-memory index serving these suggestions under billions of queries per day?

System DesignTechnical Trade-offs
Author's notes

Prefix hash sharding was my answer.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the scale and requirements (e.g., index size, query latency, consistency needs), then propose a sharding strategy (e.g., by prefix or hash) and discuss scaling techniques like replication, caching, and load balancing. Emphasize trade-offs between consistency, latency, and cost, and how you would handle hot shards and rebalancing.

Pro tip: Mention that you would shard by the query prefix (e.g., first few characters) to ensure even distribution and enable efficient prefix-based lookups, and discuss how to handle hot shards with techniques like dynamic splitting or caching.

1. Clarify Requirements and Constraints

Ask about the size of the index, query patterns (read-heavy, write frequency), latency SLA, consistency requirements, and budget. This ensures your design meets actual needs.

2. Choose a Sharding Strategy

Decide between range-based (e.g., by prefix) or hash-based sharding. Consider data distribution, query patterns, and ease of rebalancing. For suggestions, prefix-based sharding often works well.

3. Design for Scalability and Fault Tolerance

Use replication for high availability and read scalability. Implement load balancing, caching (e.g., CDN or in-memory), and consider multi-tier architecture (e.g., edge caches, regional clusters).

4. Address Hot Shards and Rebalancing

Plan for hot shards due to popular prefixes. Use techniques like dynamic splitting, consistent hashing, or moving shards. Discuss monitoring and auto-scaling.

5. Discuss Trade-offs and Alternatives

Compare your approach with alternatives (e.g., different sharding keys, using a distributed cache like Redis vs. custom solution). Highlight trade-offs in latency, consistency, cost, and complexity.

Key Points to Mention

  • Sharding by prefix (e.g., first 2-3 characters) to distribute load evenly and enable efficient range queries.
  • Replication and read replicas to handle billions of queries per day and ensure high availability.
  • Caching strategies (e.g., in-memory caches, CDN) to reduce latency and load on shards.
  • Handling hot shards via dynamic splitting, consistent hashing, or dedicated shards for popular prefixes.
  • Monitoring and auto-scaling to adapt to traffic changes and rebalance shards.
  • Trade-offs between consistency, latency, and cost (e.g., eventual consistency vs. strong consistency).

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