← Roku Interview Insights

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

SeniorPrefer not to say
May 2026

Summary

System design round at Roku for a software engineer role, focused entirely on ad infrastructure. One meaty question about frequency capping that went pretty deep into distributed systems territory.

Questions Asked (1)

Q1

Design the frequency capping component of an ad-serving system. How do you prevent the same ad from being shown to the same user too many times within a rolling time window?

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 'too many times' (e.g., max 3 impressions per user per ad per day) and the rolling window (e.g., 24 hours). Then propose a scalable, low-latency solution using a distributed in-memory store like Redis with per-user per-ad counters and TTLs, and discuss trade-offs between accuracy, latency, and cost.

Pro tip: Mention that frequency capping must be enforced at ad-serving time with minimal latency (<10ms), so precomputing or caching counts is essential; also highlight the need to handle clock skew and eventual consistency in distributed systems.

1. Clarify Requirements

Ask about the definition of frequency cap (e.g., max impressions per user per ad per time window), the size of the rolling window, and whether it's per ad, per campaign, or per advertiser. Also clarify scale (users, ads, QPS) and latency requirements.

2. High-Level Design

Propose a distributed key-value store (e.g., Redis) to track impression counts per user per ad with TTL equal to the rolling window. For each ad request, check the count; if below cap, serve ad and increment count atomically.

3. Data Modeling and Key Design

Design keys like 'freq:{userId}:{adId}' storing a counter, or use a sorted set of timestamps for precise rolling windows. Discuss memory footprint and eviction policies.

4. Scalability and Consistency

Address sharding by user ID, replication for high availability, and trade-offs between strong consistency (using atomic increments) and eventual consistency (using local caches with periodic sync). Consider using a write-through cache or a dedicated frequency capping service.

5. Trade-offs and Edge Cases

Discuss trade-offs: exact counting vs. approximate (e.g., using probabilistic data structures like count-min sketch), latency vs. accuracy, and cost. Handle edge cases like clock skew, TTL expiration, and failure scenarios (e.g., Redis down).

Key Points to Mention

  • Use of Redis or similar in-memory store with TTL for rolling window
  • Atomic increment operations (e.g., INCR) to avoid race conditions
  • Sharding by user ID for scalability
  • Trade-offs between exact and approximate counting (e.g., count-min sketch)
  • Handling of distributed consistency and clock skew
  • Fallback strategies when the frequency capping service is unavailable

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