← Roku Interview Insights

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

Senior
Apr 2026

Summary

Roku system design round for a software engineer role. The whole thing was basically one deep question about ad frequency capping, and they wanted you to go pretty far into the weeds on distributed systems tradeoffs.

Questions Asked (1)

Q1

Design a component of an ad-serving system that prevents the same ad from being shown to the same user too many times within a given time window. Walk through event collection, aggregation, counter storage, and the tradeoffs involved.

System DesignTechnical Trade-offsData Modeling
Author's notes

This one sprawled fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: define the time window, frequency cap, and scale (e.g., 100M users, 1B ad impressions/day). Then design a pipeline: event collection via a message queue, aggregation using a stream processor, and counter storage in a low-latency store like Redis with TTL. Finally, discuss tradeoffs between accuracy, latency, and cost, and how to handle edge cases like late events and hot keys.

Pro tip: Emphasize that frequency capping is a tradeoff between user experience and ad revenue, and propose a hybrid approach: use approximate counting (e.g., HyperLogLog) for high-frequency users to save memory, while exact counting for the majority. Also, mention that Roku's ad system likely deals with TV devices, so consider device-level capping and household sharing.

1. Clarify Requirements and Scale

Ask about the time window (e.g., 24 hours), frequency cap (e.g., 3 times), and scale (users, ads, QPS). Also clarify if capping is per user, per device, or per household, and the acceptable latency for ad serving.

2. Design Event Collection

Propose a high-throughput, fault-tolerant ingestion pipeline: ad events (impressions) are sent to a message queue like Kafka, partitioned by user ID to ensure ordering and scalability. Mention the need for deduplication and handling late events.

3. Design Aggregation and Counter Storage

Use a stream processor (e.g., Flink) to aggregate counts per user per ad within the time window. Store counters in a low-latency, distributed store like Redis with TTL for automatic expiration. Discuss using atomic increments and read-modify-write patterns.

4. Integrate with Ad Serving

At ad request time, query the counter store to check if the user has exceeded the cap. If so, filter out that ad. Discuss caching and pre-computation to meet low-latency requirements (e.g., <100ms).

5. Discuss Tradeoffs and Edge Cases

Cover tradeoffs: exact vs. approximate counting, memory vs. accuracy, latency vs. consistency. Address edge cases: late events, hot keys (e.g., popular users), counter expiration, and failure recovery.

Key Points to Mention

  • Use of a distributed message queue (Kafka) for scalable event collection with partitioning by user ID.
  • Stream processing (e.g., Flink, Spark Streaming) for real-time aggregation and windowing.
  • Low-latency counter storage (Redis) with TTL for automatic expiration and atomic increments.
  • Tradeoffs: exact counting (high memory) vs. approximate counting (HyperLogLog) for scalability.
  • Handling late events and out-of-order data using watermarks or event-time processing.
  • Integration with ad serving: pre-computed counters or caching to meet latency SLAs.

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