← Netflix Interview Insights

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

Senior
May 2026

Summary

Netflix system design round for a software engineering role. One question, focused entirely on ads frequency capping with a rolling window. The expectation to walk through both read and write paths clearly made it more involved than I expected.

Questions Asked (1)

Q1

Design an ads frequency capping system using a rolling window. Walk through the read and write paths clearly.

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

The rolling window part is where I got a bit tangled.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: what is the cap (e.g., 3 ads per hour), window size, and acceptable latency. Then design a distributed system using a time-series data store (e.g., Redis sorted sets or a sliding window counter) to track ad views per user, and detail the read path (checking if cap exceeded) and write path (recording a view) with consistency and scalability in mind.

Pro tip: Emphasize the trade-off between accuracy and performance: exact rolling windows require storing individual timestamps, while approximate methods (e.g., sliding window counters with buckets) reduce memory but may slightly over- or under-count. Netflix likely values scalability and low latency, so propose a hybrid approach.

1. Clarify Requirements and Constraints

Ask about the cap definition (e.g., max ads per user per hour), window type (rolling vs. fixed), expected scale (users, ads per second), latency requirements, and consistency needs (strict vs. eventual).

2. Choose Data Model and Storage

Select a data store that supports efficient time-based queries, such as Redis sorted sets (timestamp as score) or a sliding window counter using multiple buckets. Consider sharding by user ID for scalability.

3. Design the Read Path

On ad request, query the store to count events within the rolling window. If count < cap, allow ad; else, deny. Use caching or read replicas to reduce latency, and handle eventual consistency if using distributed counters.

4. Design the Write Path

When an ad is shown, record the event with timestamp. For sorted sets, add member with current timestamp and remove old entries (e.g., older than window). For bucket counters, increment the current bucket and optionally expire old buckets.

5. Address Scalability and Trade-offs

Discuss partitioning, replication, and failure handling. Compare exact vs. approximate counting, and explain how to handle high throughput (e.g., write batching, async processing) while maintaining low latency for reads.

Key Points to Mention

  • Rolling window implementation using Redis sorted sets (ZADD, ZREMRANGEBYSCORE, ZCARD) or sliding window counters with time buckets.
  • Read path optimization: caching, read replicas, and pre-computed counts to meet low-latency requirements.
  • Write path efficiency: batching writes, using Lua scripts for atomic operations, and setting TTLs for automatic cleanup.
  • Trade-offs between exact counting (memory-intensive) and approximate counting (e.g., using probabilistic data structures like count-min sketch).
  • Scalability considerations: sharding by user ID, using a distributed cache like Redis Cluster, and handling hot keys.
  • Consistency and failure modes: eventual consistency vs. strong consistency, idempotency of writes, and fallback strategies if the store is unavailable.

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