System design
Media Staff 27 min read

Design Netflix

Design Netflix's video streaming platform: content ingestion with Mezzanine encoding, Open Connect CDN with ISP-embedded appliances, adaptive bitrate streaming, DRM, and the collaborative filtering recommendation engine behind 80% of content discovery.

Tags streamingcdnopen-connectdrmadaptive-bitraterecommendationschaos-engineering

The scale of the problem

Netflix’s streaming platform carries a burden that is simultaneously enormous and deceptively simple. With 238 million paid subscribers across 190 countries, Netflix accounts for approximately 15% of global downstream internet traffic during peak hours in North America. On any given day, subscribers watch more than 100 million hours of content — a number that understates the engineering challenge because those hours are not uniformly distributed. Peak demand hits between 8 and 11 PM in each time zone, and when a major original series drops a new season, the spike is vertical: tens of millions of subscribers attempting to stream simultaneously within the first few hours of release. The system must absorb that spike without a single buffering spinner appearing in a single living room.

The key insight that shapes Netflix’s entire infrastructure is the Open Connect program, launched in 2012. Before Open Connect, Netflix used third-party CDNs (Akamai, Level 3) and paid transit bandwidth costs to deliver content. These transit costs grow linearly with traffic — a catastrophic economic model for a company whose traffic doubles every few years. Netflix’s insight was that ISPs have the same incentive to avoid transit costs: when a Netflix subscriber in a Comcast home watches a movie, the video packets travel from Netflix’s CDN provider → a transit provider → a peering point → Comcast’s backbone → the subscriber’s home. Every hop costs money for both sides. Open Connect eliminates every hop except the last one by placing Netflix-owned server appliances (OCAs) directly inside ISP data centers. The ISP benefits because Netflix traffic never leaves their network, reducing transit costs. Netflix benefits because it eliminates per-byte transit fees and reduces latency to a single hop. Netflix installs these appliances free of charge; the ISP provides rack space and power. At 17,000 OCAs serving 95% of Netflix’s traffic, Open Connect is arguably the largest proprietary CDN ever built by a non-CDN company.

Netflix’s problem is fundamentally different from YouTube’s in ways that matter architecturally. YouTube is a user-generated content platform: millions of short-to-medium uploads per day, no DRM, no per-title encoding investment justified at the individual video level. Netflix is a licensed content platform: a catalog of roughly 36,000 titles, all professionally produced, all requiring DRM, and each worth enough investment to justify 1,200 custom encodes per title. Netflix can spend compute resources optimizing a single movie’s encoding because that movie will be watched hundreds of millions of times; YouTube cannot justify the same per-video investment on a 47-second clip that will be watched 200 times. This asymmetry justifies Netflix’s Consistent Encoding approach — spending weeks of compute on each title to find the optimal bitrate ladder — in a way that would be economically irrational for a UGC platform.

Clarifying questions

Lock down these eight questions before sketching any architecture. Each answer closes a major design branch and exposes the DRM, encoding, or CDN requirements that follow from it.

QuestionIdeal AnswerWhy It Matters
What is the content length range and type?Episodic TV (20–60 min episodes) and movies (90 min–3 hr); Netflix Originals only, no UGCDrives encoding investment per title — longer, professionally produced content justifies 1,200 per-title encodes; UGC would require a cheaper, lower-quality fixed ladder
What quality targets must you support?SD (480p), HD (1080p), 4K HDR (2160p with Dolby Vision and HDR10)4K + HDR doubles encoding complexity and requires hardware-level DRM (Widevine L1, FairPlay hardware decode); determines codec selection — H.264 for SD/HD, HEVC and AV1 for 4K
Is offline download required?Yes — subscribers can download titles to mobile devices for offline viewingDRM license must be pre-fetched, device-bound, and time-limited at download time; requires a separate offline license flow distinct from streaming
How many concurrent streams per account?4 simultaneous streams on separate devicesLicense server must validate concurrent stream count per account before issuing a new license; requires a concurrency tracking service
Is DRM required?Yes — mandatory for all content, all devices; content owners require it contractuallyWidevine, FairPlay, and PlayReady must all be implemented; CENC Common Encryption lets one encrypted encode serve multiple DRM systems
Is live streaming in scope?Live events only (award shows, sports) — separate system with different latency requirementsLive streaming requires a completely different ingest pipeline (RTMP ingest, low-latency HLS/DASH with 2-second segments), separate CDN configuration, and no pre-positioning
Is there user-generated content?No — Netflix is licensed content onlyEliminates the abuse detection, copyright fingerprinting, and cheap-ladder encoding pipelines required for UGC platforms
Are geographic content licensing restrictions required?Yes — catalog varies by region; a title available in the US may be geo-blocked in EuropeManifests must be region-scoped; the Playback Service must check regional entitlement before issuing a signed URL; OCA pre-positioning must respect regional availability

Functional requirements

  • Subscribers can browse the content catalog with personalized recommendations sorted by predicted engagement, filterable by genre, and paginated for infinite scroll.
  • Subscribers can play any title in their region-specific catalog at the highest quality their device and connection support, with seamless adaptive bitrate switching that adjusts segment quality without interrupting playback.
  • Subscribers can download titles to mobile devices for offline viewing, subject to DRM license duration and maximum device count per account.
  • Accounts support multiple profiles (up to 5) with independent watch history, recommendations, and maturity-rating filters; playback state is synchronized across devices per profile.
  • The recommendation engine surfaces relevant titles on the home page, in post-play suggestions, and in the “More Like This” row, accounting for watch history, time-of-day patterns, and regional popularity.
  • Playback state (resume position) is persisted and synchronized across devices so a subscriber can start a title on their TV and finish it on their phone without manual seeking.

Non-functional requirements

  • Scale: 238 million paid subscribers; 100 million+ hours of content watched per day; 4.17 million concurrent streams at peak.
  • Playback start latency: p99 < 2 seconds from the user pressing Play to the first video frame rendered, including manifest fetch, DRM license, and first segment download.
  • Buffering ratio: < 0.1% of playback time spent buffering (a Netflix internal KPI); measured as rebuffer events per 100 hours of watch time.
  • Availability: 99.99% annual uptime for the streaming path (playback + CDN); this allows less than 52 minutes of total downtime per year.
  • DRM compliance: Widevine L1/L3, FairPlay, and PlayReady — contractually mandated by content owners for all titles; 4K content restricted to hardware DRM (L1/FairPlay hardware path) only.
  • Storage durability: 99.999999999% (11 nines) for encoded content on S3; content is the company’s most valuable asset and must survive any regional AWS failure.

API design

Catalog and browse

GET /api/v3/catalog?profile_id={id}&genre={g}&page={p}&page_size=20
    Returns: { titles: [{title_id, title, synopsis, thumbnail_url,
                maturity_rating, runtime_sec, genres, match_score}],
               next_page_token, total_results }
GET /api/v3/titles/{title_id}
    Returns: { title_id, type (movie|series|episode), title, synopsis,
               cast[], directors[], release_year, runtime_sec, content_rating,
               genres[], is_original, available_regions[], trailer_url,
               episodes: [{episode_id, season, episode, title, synopsis}] }

Playback initiation — the critical path

POST /api/v3/playback/manifest
     Body:    { title_id, profile_id, device_type (MOBILE|TV|BROWSER|CONSOLE) }
     Returns: { manifest_url (signed, 10-min TTL),
                license_url,
                expiry_epoch,
                supported_drm: ["widevine"|"fairplay"|"playready"],
                concurrent_stream_token }

The Playback Service performs four operations before returning this response: validate the subscriber’s entitlement for this title in their region, check concurrent stream count (reject if at limit), select the nearest healthy OCA for the client IP, and sign the manifest URL with an HMAC-SHA256 token that the OCA validates before serving the manifest. The entire operation must complete in under 300 ms to keep playback start latency within the 2-second budget.

Manifest download — served from OCA, not origin

GET {signed_manifest_url}
    e.g. https://oca-comcast-sjc-04.netflix.com/manifests/{title_id}/{region}/TV.mpd
    Returns: DASH MPD (XML) listing all encode variants, segment URLs, codec parameters

DRM license request

POST /api/v3/license
     Body: { title_id, profile_id, device_cert (base64), drm_challenge (base64),
             drm_type (widevine|fairplay|playready),
             concurrent_stream_token }
     Returns: { license (base64-encoded DRM license blob containing AES-128 key) }

Telemetry — continuous during playback

POST /api/v3/playback/events
     Body: { title_id, profile_id, position_sec, event_type (play|pause|seek|buffer|complete|error),
             quality_level (bitrate_kbps, resolution, codec),
             rebuffer_duration_ms, device_type, oca_host }

Telemetry events are batched client-side every 60 seconds and on playback state changes, then published to Kafka on the server side. The pipeline feeds Netflix’s Keystone real-time analytics system and is used for OCA health scoring, per-title quality-of-experience monitoring, and ABR algorithm tuning.

Recommendations

GET /api/v3/recommendations?profile_id={id}&context={home|similar|postplay}&limit=50
    Returns: { title_ids: ["tt001", "tt002", ...], algorithm_version, experiment_id }

Data model

titles — MySQL with read replicas (catalog is read-heavy, schema changes infrequent):

CREATE TABLE titles (
  title_id        VARCHAR(36)   PRIMARY KEY,
  type            ENUM('movie','series','episode') NOT NULL,
  title           VARCHAR(512)  NOT NULL,
  synopsis        TEXT,
  runtime_sec     INT,
  release_year    SMALLINT,
  content_rating  VARCHAR(16),
  is_original     BOOLEAN       NOT NULL DEFAULT FALSE,
  genres          JSON,
  available_regions JSON,
  created_at      TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP,
  INDEX idx_type (type),
  INDEX idx_original (is_original),
  FULLTEXT idx_search (title, synopsis)
);

encodes — MySQL, write-once (encoding pipeline inserts, playback reads):

CREATE TABLE encodes (
  encode_id       VARCHAR(36)   PRIMARY KEY,
  title_id        VARCHAR(36)   NOT NULL,
  codec           ENUM('h264','hevc','av1','vp9') NOT NULL,
  resolution      VARCHAR(16)   NOT NULL,
  bitrate_kbps    INT           NOT NULL,
  s3_key          TEXT          NOT NULL,
  vmaf_score      DECIMAL(5,2),
  duration_sec    INT,
  is_hdr          BOOLEAN       NOT NULL DEFAULT FALSE,
  hdr_type        ENUM('hdr10','dolby_vision','hlg') NULL,
  segment_duration_sec SMALLINT NOT NULL DEFAULT 4,
  created_at      TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP,
  INDEX idx_title (title_id),
  INDEX idx_title_codec (title_id, codec, resolution)
);

manifests — stored in S3, generated once per title per region per device class:

s3_key_pattern: manifests/{title_id}/{region}/{device_type}.mpd
content_type: application/dash+xml
cache_control: max-age=3600
notes: >
  DASH MPD XML listing all encode variants with signed segment URL templates.
  Regenerated whenever encode set changes or regional availability changes.
  Also available as HLS (.m3u8) for Apple devices under manifests/{title_id}/{region}/{device_type}.m3u8

user_profiles — MySQL:

CREATE TABLE user_profiles (
  profile_id      VARCHAR(36)   PRIMARY KEY,
  account_id      VARCHAR(36)   NOT NULL,
  name            VARCHAR(128)  NOT NULL,
  avatar_url      TEXT,
  language        CHAR(5)       NOT NULL DEFAULT 'en-US',
  maturity_rating VARCHAR(16)   NOT NULL DEFAULT 'ALL',
  content_prefs   JSON,
  created_at      TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP,
  INDEX idx_account (account_id)
);

watch_history — Cassandra (time-series access pattern: write on every event, read by profile sorted by recency):

CREATE TABLE watch_history (
  profile_id      UUID,
  watched_at      TIMESTAMP,
  title_id        UUID,
  position_sec    INT,
  completed       BOOLEAN,
  quality_stats   TEXT,
  PRIMARY KEY (profile_id, watched_at, title_id)
) WITH CLUSTERING ORDER BY (watched_at DESC)
  AND default_time_to_live = 7776000;

recommendations — Redis (hot layer) + offline DynamoDB (cold layer):

redis_key_pattern: "recs:{profile_id}:{context}"
redis_value: JSON array of title_ids ordered by predicted engagement score
redis_ttl: 3600 seconds
cold_store: DynamoDB table recommendations, partition key profile_id, sort key context
cold_store_notes: >
  Written nightly by the batch recommendation pipeline.
  Redis is populated on first request (cache-aside pattern), evicted after 1 hour.
  If Redis misses, read from DynamoDB, then call real-time ranking service to re-score.

concurrent_streams — Redis (sub-millisecond read required at license issuance):

redis_key_pattern: "streams:{account_id}"
redis_type: Hash
redis_field: "{stream_token}"
redis_value: "{profile_id}:{title_id}:{started_at_epoch}:{device_type}"
redis_ttl: refreshed on each telemetry heartbeat (60s); expires if no heartbeat
max_streams: 4 (configurable per subscription tier)

Architecture diagrams

Content ingestion pipeline — from studio to OCA:

Playback request flow — client to OCA:

Deep dives

Consistent Encoding and per-title optimization

Traditional video encoding services use a fixed bitrate ladder: every title is encoded at the same set of resolutions and bitrates regardless of content complexity. A typical fixed ladder might be: 240p at 400 Kbps, 480p at 1 Mbps, 720p at 2.5 Mbps, 1080p at 5 Mbps, 4K at 15 Mbps. This is simple to operate and produces predictable file sizes, but it is deeply inefficient: a simple animated cartoon has almost no texture complexity and can achieve excellent perceptual quality at 2.5 Mbps for 1080p; a fast-action thriller with dark scenes, motion blur, and film grain may need 8 Mbps to achieve the same perceived quality at 1080p.

Netflix introduced Consistent Encoding in 2015 and Dynamic Optimizer in 2017. The core idea is to measure perceptual quality rather than treat bitrate as a proxy for quality. VMAF (Video Multi-Method Assessment Fusion) is Netflix’s open-source quality metric that correlates well with human perceptual quality judgments. It combines multiple existing metrics (DLM, VIF, motion) using a Support Vector Machine trained on human quality scores from blind viewing tests. A VMAF score of 93 on a 0–100 scale represents the threshold where trained viewers rate quality as “transparent” — indistinguishable from the original.

Per-title optimization works as follows: for each title, Netflix’s encoding farm produces trial encodes at many bitrate points across each resolution, measures VMAF for each, and fits a convex hull curve (VMAF vs. bitrate). The production encode for that resolution is cut at the bitrate where the curve reaches the target VMAF threshold. Animation content (Disney-style, solid colors, minimal texture) reaches VMAF 93 at 1080p with only 2 Mbps — far below the fixed-ladder’s 5 Mbps for that resolution. A dark, grain-heavy thriller requires 8 Mbps to reach the same threshold. Per-title optimization therefore produces encodes that are 20–40% smaller on average for equivalent perceptual quality, reducing OCA storage costs and subscriber bandwidth consumption simultaneously.

The 1,200 encodes per title figure is not arbitrary. Netflix’s encode matrix includes: 6 codecs (H.264 Baseline, H.264 Main, HEVC, VP9, AV1, Dolby Vision Profile 8), 5 resolutions (360p, 480p, 720p, 1080p, 4K), 4 HDR variants (SDR, HDR10, Dolby Vision, HLG), and approximately 10 bitrate points per resolution-codec-HDR combination. The number varies per title because the per-title VMAF analysis determines which bitrate points are on the efficient frontier. Some low-complexity content has only 4 meaningful bitrate points before VMAF plateaus; high-complexity content may use all 10. Netflix also encodes audio separately across multiple codecs (AAC, Dolby Digital Plus, Atmos) and languages, adding further encode variants. The encoding pipeline runs on thousands of EC2 instances (spot instances for cost efficiency) and typically takes 24–72 hours per title.

Open Connect CDN architecture

The Open Connect Appliance (OCA) is custom hardware built specifically for video delivery. Each OCA is a high-density storage server with 200 TB to 1 PB of HDD capacity, a large DRAM cache (1–4 TB for the “hot” tier), and a 100 Gbps network interface. Netflix installs these appliances in ISP data centers free of charge, pays only for the hardware, and the ISP provides rack space, power, and network connectivity. The value exchange is straightforward: Netflix saves transit costs (which at 20 Tbps peak would be hundreds of millions of dollars annually at commodity transit prices), and the ISP saves backbone transit costs because Netflix traffic never leaves the ISP’s internal network.

Content pre-positioning is the key operational challenge. Each OCA holds roughly 100–200 TB of content depending on appliance generation. The Netflix catalog is 432 PB, so no single OCA holds the complete catalog — each appliance holds only the titles most likely to be watched by subscribers on that ISP in that region in the coming day. Netflix runs a popularity prediction model each night (features: global trending, regional trending, day-of-week patterns, scheduled releases) and generates a pre-positioning plan that pushes the top-N titles for each OCA’s subscriber base onto that appliance. Pre-positioning happens over the ISP’s internal backbone at off-peak hours (3–6 AM local time) using a proprietary file distribution protocol. Popular long-tail titles that don’t make the pre-positioning cut are fetched from S3 origin on first request and cached on the OCA’s SSD tier for subsequent requests from the same appliance.

OCA selection at playback time is performed by the Playback Service, which maps the client’s IP address to a BGP prefix, looks up which ISP and geographic region that prefix belongs to, and then queries a health-scored list of candidate OCAs for that ISP and region. Health scoring is computed continuously from telemetry: each OCA reports its current load, available bandwidth, and error rate to a fleet management service. If an OCA is at 95% capacity or reporting errors above threshold, it is excluded from the candidate list. The Playback Service picks the highest-scored healthy OCA and embeds its hostname in the signed manifest URL. If no healthy OCA exists for a client’s ISP (possible in new geographies or during major failures), the Playback Service falls back to a regional OCA cluster or ultimately to a third-party CDN fallback.

The CDN fallback path is important for the “Netflix in a new country” scenario: before Open Connect appliances are deployed in a new ISP, Netflix uses third-party CDN (CloudFront, Akamai) as a fallback. The Playback Service selects this fallback automatically based on the absence of a healthy OCA for the client’s prefix. This means the product works from day one in new geographies at higher cost, while OCA deployment proceeds on the 6–12 month ISP partnership timeline.

DRM and content protection

Content protection at Netflix operates at three layers: encryption of the media files, issuance of decryption keys to authorized clients, and hardware-level enforcement on high-value content.

All Netflix content is encrypted with AES-128 in the CENC (Common Encryption) scheme defined by ISO/IEC 23001-7. CENC’s key innovation is that the encrypted content is DRM-agnostic — the same encrypted MP4 or MPEG-TS segment can be decrypted by any DRM system that has the key. This means Netflix stores only one encrypted version of each encode on S3 and the OCAs, rather than one version per DRM system. The three DRM systems each have their own license format and key delivery mechanism, but they all ultimately produce the same AES-128 key to decrypt the content.

Widevine (Google) covers Android devices, Chrome browser, Chromecast, and Android TV. Widevine defines three robustness levels: L3 (fully software-based decryption, maximum 1080p, no 4K), L2 (hardware crypto, software decode), and L1 (hardware crypto with hardware secure video path — the video signal never enters system memory unencrypted, required for 4K and HDR on Android). Netflix requires L1 for 4K streams on Android devices, which means the phone or TV must have a Trusted Execution Environment (TEE) that implements Widevine L1. FairPlay (Apple) covers iOS, iPadOS, tvOS, and Safari on macOS — Apple’s DRM is hardware-enforced on all Apple Silicon and recent Intel-based devices. PlayReady (Microsoft) covers Windows, Xbox, and the Edge browser — Microsoft’s hardware-enforced path (SL3000) is required for 4K on Windows devices.

The license request flow during playback: the client’s DRM module generates a challenge (a signed blob containing the device certificate, a nonce, and the content ID) and sends it to Netflix’s license server. The license server validates the challenge against the device certificate (which is burned into hardware by the device manufacturer and signed by the DRM provider’s root CA), checks the subscriber’s account entitlement and concurrent stream count, and issues a short-lived license blob containing the AES-128 content key encrypted with the device’s public key. The license is device-bound and typically valid for 24–48 hours for streaming. For offline downloads, the license is fetched at download time and bound to the device’s hardware key with an expiration date matching the subscriber’s subscription end date. If the subscription lapses, the offline license expires and the downloaded content cannot be decrypted.

License server availability is a direct dependency of playback availability — if the license server is unreachable, 4K subscribers cannot start new streams. Netflix addresses this by deploying license servers in multiple AWS regions behind a global load balancer (Route 53 latency routing) and using circuit breakers to fail fast to backup regions. License renewal for in-progress streams is handled by the client refreshing the license 30 minutes before expiry, with exponential backoff retry logic.

Recommendation system

Netflix’s recommendation system is responsible for 80% of the content subscribers choose to watch. The remaining 20% comes from active search or browsing by genre. This means that if the recommendation system degrades, subscriber engagement drops immediately — making it a tier-1 system with the same availability requirements as playback.

The system operates in two stages. Candidate generation produces a manageable shortlist of titles from the full catalog using computationally efficient methods. Ranking scores and orders the shortlist using richer features at lower computational cost (because the set is already small).

For candidate generation, Netflix uses multiple independent generators that each produce a candidate set, which are then fused. The primary generator is matrix factorization using Alternating Least Squares (ALS). ALS decomposes the watch history matrix (subscribers × titles, where each cell is an implicit signal like completion rate) into two embedding matrices: a subscriber embedding (latent preferences) and a title embedding (latent content characteristics). Each subscriber and title is represented as a 128-dimensional vector. Finding similar titles for a given subscriber is an ANN (Approximate Nearest Neighbor) search in this embedding space — Netflix uses their Faiss-based system to search over 36,000 title embeddings in under 10 ms. Additional candidate generators include: trending in the subscriber’s region (surfaced via Kafka-powered real-time counts), similar-to-recently-watched (using title embedding cosine similarity), and editorial collections (curated by Netflix’s programming team for holidays, events, etc.). These candidate sets are merged and deduplicated, producing approximately 500 candidates per subscriber per context.

Ranking is performed by a gradient-boosted model (historically XGBoost; Netflix has also published work on deep learning ranking models) that takes the 500 candidates and scores each against a rich feature set: predicted watch probability (will the subscriber click?), predicted completion rate (will they finish?), time-of-day preference (action on weekday evenings, comedy on weekend afternoons — derived from historical watch time patterns), diversity penalty (avoid three consecutive titles from the same series), novelty score (penalize recently seen titles), and regional popularity boost (localized content performs better in its home region). The output is a ranked list of title IDs returned to the catalog API.

Context matters significantly. The home page recommendation context optimizes for predicted engagement across a broad catalog. The post-play context (what shows after an episode finishes) optimizes for titles with high predicted watch probability given the just-completed title — effectively next-episode or similar-series suggestions. The search context is intent-signal dominated — the query term directly constrains the candidate set before ranking. Netflix runs A/B experiments continuously on both the candidate generators and the ranking model, with experiments allocated at the account level (not the request level, to avoid intra-user inconsistency). Netflix’s experimentation platform (based on their internal A/B framework) runs hundreds of simultaneous recommendation experiments at any given time.

Chaos Engineering and resilience

Netflix invented the discipline of chaos engineering, beginning with Chaos Monkey in 2011. The philosophy is that in a distributed system at scale, failures are not exceptional events — they are continuous background phenomena. The question is not whether a dependency will fail, but whether your system degrades gracefully when it does. Chaos experiments answer this question empirically by injecting failures in production, with blast radius controls, and measuring the impact on subscriber experience metrics (stream start latency, rebuffer ratio, availability).

Chaos Monkey randomly terminates EC2 instances in production during business hours. The blast radius is one instance at a time; stateless services (like the Playback Service) recover immediately because the load balancer routes requests to surviving instances. Stateful components (like Cassandra nodes) recover more slowly; Chaos Monkey’s termination of a Cassandra node verifies that the ring’s replication factor (RF=3 in most deployments) allows reads and writes to continue across the remaining nodes. Chaos Kong is a higher-order experiment: it terminates an entire AWS Availability Zone (or in some exercises, an entire region), verifying that Netflix’s multi-region active-active deployment can absorb complete regional failure. Netflix runs three active AWS regions simultaneously (US-East-1, EU-West-1, AP-Southeast-1) with global traffic steering via Route 53. Any one region failing affects approximately 20–35% of subscribers, who are re-routed to the next-closest region within the DNS TTL window (~60 seconds).

Latency Monkey injects artificial latency into inter-service HTTP calls, simulating slow dependencies. This tests whether circuit breakers are correctly calibrated. Netflix uses Hystrix (now in maintenance) and its spiritual successor Resilience4j for circuit breaking: when a downstream service’s p99 response time exceeds a threshold or its error rate exceeds a percentage threshold, the circuit opens and the calling service immediately returns a fallback response rather than waiting for the timeout. For recommendations, the fallback is to return the regional trending list (computed offline and cached in Redis) rather than the personalized list. For the license server, the fallback is to allow in-progress streams to continue (the client already has a valid license) while new stream starts queue with retry logic. For OCA selection, the fallback is a third-party CDN or an adjacent OCA cluster.

The application of chaos engineering to system design interviews is this: any system you design at scale should have explicit answers to three questions for each critical dependency. First, what is the graceful degradation behavior when this dependency is slow? (Circuit breaker → fallback). Second, what is the graceful degradation behavior when this dependency is completely unavailable? (Fallback service or cached response). Third, have you defined the blast radius — what percentage of users are affected by a failure in this component? Designing for degradation rather than failure avoidance is the engineering mindset that separates staff-level system design from senior-level.

Java integration

Part A — PlaybackService.java

package com.netflix.playback.service;

import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Base64;
import java.util.List;

@Service
public class PlaybackService {

    private static final int SIGNED_URL_TTL_SECONDS = 600;
    private static final String LICENSE_BASE_URL = "https://license.netflix.com";
    private static final String HMAC_KEY = System.getenv("URL_SIGNING_KEY");

    private final OcaSelector ocaSelector;
    private final UserEntitlementService userService;
    private final KafkaTemplate<String, String> kafka;

    public PlaybackService(OcaSelector ocaSelector,
                           UserEntitlementService userService,
                           KafkaTemplate<String, String> kafka) {
        this.ocaSelector = ocaSelector;
        this.userService = kafka == null ? null : userService;
        this.kafka = kafka;
    }

    public PlaybackManifest getManifest(String titleId, String profileId,
                                        String clientIp, DeviceType deviceType) {
        String region = userService.getRegion(profileId);
        userService.checkEntitlement(profileId, titleId, region);
        userService.checkConcurrentStreamLimit(profileId);

        OcaEndpoint oca = ocaSelector.selectOca(clientIp);
        String manifestPath = String.format("https://%s/manifests/%s/%s/%s.mpd",
                oca.host(), titleId, region, deviceType.name().toLowerCase());
        String signedUrl = signUrl(manifestPath, SIGNED_URL_TTL_SECONDS);

        String drmType = deviceType == DeviceType.MOBILE ? "widevine"
                       : deviceType == DeviceType.TV    ? "fairplay"
                       : "widevine";
        String licenseUrl = String.format("%s/%s/%s", LICENSE_BASE_URL, drmType, titleId);

        long expiresAt = Instant.now().getEpochSecond() + SIGNED_URL_TTL_SECONDS;
        String streamToken = profileId + ":" + titleId + ":" + expiresAt;

        kafka.send("playback-events", profileId,
                String.format("{\"event\":\"start\",\"title_id\":\"%s\","
                        + "\"profile_id\":\"%s\",\"oca\":\"%s\"}",
                        titleId, profileId, oca.host()));

        return new PlaybackManifest(signedUrl, licenseUrl, expiresAt, streamToken);
    }

    private String signUrl(String url, int ttlSeconds) {
        try {
            long expiry = Instant.now().getEpochSecond() + ttlSeconds;
            String payload = url + "|" + expiry;
            Mac mac = Mac.getInstance("HmacSHA256");
            mac.init(new SecretKeySpec(HMAC_KEY.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
            String sig = Base64.getUrlEncoder().withoutPadding()
                    .encodeToString(mac.doFinal(payload.getBytes(StandardCharsets.UTF_8)));
            return url + "?expires=" + expiry + "&sig=" + sig;
        } catch (Exception e) {
            throw new RuntimeException("URL signing failed", e);
        }
    }

    public record PlaybackManifest(String signedManifestUrl, String licenseUrl,
                                   long expiresAt, String streamToken) {}

    public enum DeviceType { MOBILE, TV, BROWSER, CONSOLE }

    public record OcaEndpoint(String host, double healthScore) {}
}

Part B — PlaybackController.java

package com.netflix.playback.controller;

import com.netflix.playback.service.PlaybackService;
import com.netflix.playback.service.PlaybackService.DeviceType;
import com.netflix.playback.service.PlaybackService.PlaybackManifest;
import io.lettuce.core.api.sync.RedisCommands;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/api/v3")
public class PlaybackController {

    private final PlaybackService playbackService;
    private final KafkaTemplate<String, String> kafka;
    private final RedisCommands<String, String> redis;
    private final RecommendationGrpcClient recClient;

    public PlaybackController(PlaybackService playbackService,
                              KafkaTemplate<String, String> kafka,
                              RedisCommands<String, String> redis,
                              RecommendationGrpcClient recClient) {
        this.playbackService = playbackService;
        this.kafka = kafka;
        this.redis = redis;
        this.recClient = recClient;
    }

    @PostMapping("/playback/manifest")
    public PlaybackManifest getManifest(@RequestBody ManifestRequest req,
                                        HttpServletRequest httpReq) {
        String profileId = JwtUtil.extractProfileId(httpReq.getHeader("Authorization"));
        String clientIp  = httpReq.getHeader("X-Forwarded-For");
        return playbackService.getManifest(
                req.titleId(), profileId, clientIp, DeviceType.valueOf(req.deviceType()));
    }

    @PostMapping("/playback/events")
    public void recordEvent(@RequestBody PlaybackEvent event) {
        kafka.send("playback-events", event.titleId(), event.toJson());
        redis.setex("watch:" + event.profileId() + ":" + event.titleId(),
                86400, String.valueOf(event.positionSec()));
    }

    @GetMapping("/recommendations")
    public List<String> getRecommendations(@RequestParam String profileId,
                                           @RequestParam(defaultValue = "home") String context) {
        String key = "recs:" + profileId + ":" + context;
        String cached = redis.get(key);
        if (cached != null) return List.of(cached.split(","));
        List<String> titleIds = recClient.getRankedTitles(profileId, context, 50);
        redis.setex(key, 3600, String.join(",", titleIds));
        return titleIds;
    }

    @PostMapping("/license")
    public LicenseResponse proxyLicense(@RequestBody LicenseRequest req) {
        String profileId = req.profileId();
        if (redis.exists("streams:" + profileId) == 0) {
            throw new UnauthorizedException("No active stream token for profile");
        }
        return recClient.fetchLicense(req);
    }

    public record ManifestRequest(String titleId, String deviceType) {}
    public record PlaybackEvent(String titleId, String profileId, int positionSec,
                                String eventType, int qualityLevel) {
        public String toJson() {
            return String.format("{\"title_id\":\"%s\",\"position\":%d,\"event\":\"%s\"}",
                    titleId, positionSec, eventType);
        }
    }
    public record LicenseRequest(String titleId, String profileId,
                                 String deviceCert, String drmChallenge, String drmType) {}
    public record LicenseResponse(String license) {}
}

Trade-off comparison

ApproachCDN CostLatencyDRM SupportEncoding Cost
Third-party CDN (Akamai / CloudFront)High — per-GB transit pricing scales linearly with traffic; at 20 Tbps Netflix’s cost would be hundreds of millions/yearGood — global PoPs, but adds 1–2 ISP hops vs. co-located OCAFull support — third-party CDNs serve DRM-encrypted content transparentlyNone — CDN is content-agnostic
Proprietary CDN (Open Connect)Near-zero marginal cost — ISP provides rack/power; Netflix pays only hardware CapEx (~1K–1K–5K per OCA amortized over 5 years)Excellent — one ISP hop; typically 5–20 ms client to OCA vs. 30–80 ms to third-party CDN PoPFull support — OCA serves encrypted content, DRM keys served by Netflix’s license serversNone — OCA is a dumb content cache
Hybrid (OCA + third-party fallback)Low — 95% of traffic from OCA at near-zero marginal cost; 5% from third-party at full priceExcellent for most users; third-party fallback adds latency for the 5% tail (new geographies, OCA failures)Full support on both pathsNone
Fixed bitrate ladder encodingLow upfront — encode once, doneN/A — encoding affects bandwidth, not playback latencyN/ALow — one pass per resolution per codec
Per-title optimized encoding (Consistent Encoding)Lower ongoing — 20–40% smaller files at equivalent quality reduces OCA storage and subscriber bandwidthBetter quality at lower bitrate improves ABR stability (fewer quality switches)N/AHigh — multiple trial encodes per title per resolution plus VMAF measurement; 24–72 hours of compute per title on thousands of EC2 instances
Follow-up question

“Netflix is launching in a new country with no OCA appliances yet. How do you serve content at acceptable quality to the first users while the OCA partnership and deployment takes 6 months?”

Day-zero launch in a new geography is exactly where the hybrid CDN model earns its keep. The Playback Service’s OCA selection logic consults a database of OCA health scores indexed by BGP prefix. For a new country, no entries exist in this database, so the selection logic falls through to the configured CDN fallback chain: first, a regional third-party CDN PoP (CloudFront or Akamai), and if no PoP is available within acceptable latency, the global CDN edge nearest to the subscriber.

The playback experience is functional but more expensive. CloudFront CDN pricing for egress is typically 0.05–0.05–0.12 per GB depending on region; Netflix’s OCA cost is effectively 0perGBmarginal.Foracountrywithonemillionnewsubscriberswatchingtwohoursperdayat5Mbpsaverage,thedailyCDNcostis1M×2hr×3600s/hr×5Mb/s÷8=4.5PBperday×0 per GB marginal. For a country with one million new subscribers watching two hours per day at 5 Mbps average, the daily CDN cost is 1M × 2 hr × 3600 s/hr × 5 Mb/s ÷ 8 = 4.5 PB per day × 0.08/GB = $360K per day. This is economically unsustainable long-term but acceptable for a 6-month launch window while OCA negotiations close and appliances are shipped.

Simultaneously, Netflix begins the ISP partnership process: negotiate co-location agreements with the top 3–5 ISPs by subscriber count in the new country, ship OCA hardware, and work with the ISP’s network engineering team to install and configure the appliances. The first OCA cluster in the new country is typically online within 90 days of starting the process. The Playback Service’s OCA database is updated, and new subscribers’ traffic immediately begins routing to the OCA — CDN fallback traffic drops proportionally. By month six, when all major ISPs have OCA coverage, CDN fallback traffic drops below 5% and the unit economics of the new country look identical to the rest of Netflix’s footprint.

Follow-up question

“A major new season drops and 50 million users try to watch Episode 1 in the first hour. How does your OCA pre-positioning and manifest serving handle the load spike?”

A season drop of this magnitude is a known event — Netflix’s content calendar is weeks in advance. The engineering response begins days before launch, not minutes.

Pre-positioning for the new season is triggered the moment the encode pipeline completes for Episode 1 (and the first several episodes, since many subscribers binge immediately). The popularity model for this title projects 50 million streams in hour one across all geographies, which translates to approximately 50M × 5 Mbps ÷ 8 = 31 TB/s aggregate egress in the first hour. Pre-positioned content must be on every OCA appliance that serves any subscriber in the title’s licensed regions before the release time. For a major global original, this means all 17,000 OCAs simultaneously hold Episode 1’s encodes — the nightly pre-positioning run for the night before launch is pre-programmed to prioritize this title above all others.

The manifest serving bottleneck is separate from content delivery. 50 million concurrent stream starts in a 60-minute window is ~833,000 manifest requests per second. The Playback Service is a stateless Spring Boot microservice behind an AWS ALB; at peak it needs approximately 8,300 instances (assuming 100 req/s per instance). Netflix pre-scales based on projected demand: two hours before launch, the Playback Service’s auto-scaling group target is manually raised to 3x the normal peak, and the concurrent stream Redis cluster is pre-warmed. The license server fleet is similarly pre-scaled. Kubernetes horizontal pod autoscaling handles incremental scale-out, but for a known spike this magnitude, manual capacity pre-provisioning eliminates the autoscaling lag that would otherwise cause p99 latency spikes in the first 5 minutes.

For the OCAs themselves, 50M × 5 Mbps ÷ 17,000 OCAs = 15 Gbps per OCA average — within the 100 Gbps NIC headroom. However, distribution is not uniform: OCAs in major metropolitan areas with high Netflix subscriber density may see 5–10x the average, which can push toward NIC saturation. The OCA selection logic handles this through load-based scoring: as an OCA’s egress approaches 80% of NIC capacity, its health score drops and the Playback Service begins routing new requests to adjacent OCAs. This distributes the hot-title load across the OCA cluster rather than saturating individual appliances.

Follow-up question

“A user’s account is compromised and their credentials are sold — how do you detect simultaneous streaming from 20 different countries and invalidate active DRM licenses mid-stream?”

Account sharing and credential compromise are existential concerns for a subscription business. Detecting 20 simultaneous streams from 20 countries is the easy part; the hard part is invalidating active licenses without disrupting legitimate users.

Detection happens at two layers. First, the concurrent stream counter in Redis is the primary gate: when the 5th stream start request arrives for an account at stream limit, it is rejected immediately. For 20 simultaneous streams, the 5th request fails and the account triggers an anomaly flag. Second, the license server logs every license issuance with the client IP, device certificate, and geolocation. A real-time Flink pipeline on the Kafka license-events topic computes a per-account geolocation spread: if licenses are issued to IPs in 20 different countries within 30 minutes, the account’s risk score spikes and the account is flagged for review or automatic lock.

License revocation mid-stream is where DRM architecture constrains your options. DRM licenses are designed to be offline-capable — they are valid for their full duration (24–48 hours) without network connectivity. You cannot “push” a revocation to a device that is already playing. The mechanisms available are: first, when the device makes its next license renewal request (typically 30 minutes before expiry), the license server rejects it, ending the stream at that point. Second, Netflix’s client periodically polls a “heartbeat” endpoint to report the current stream; the server can respond with a terminate command, which the client honors by ending playback and displaying an account security message. Third, for the highest-severity compromise cases (account sold on a marketplace), Netflix can invalidate the account’s refresh token in the identity service, forcing all clients to re-authenticate; since DRM challenges include the user’s auth token, a re-authentication failure prevents new license issuance.

For the compromised user, the remediation flow is: automated account lock → email to registered address → password reset required → on re-authentication, all concurrent streams are terminated (via the heartbeat endpoint) and all outstanding licenses are allowed to expire without renewal. The legitimate user regains access in under 5 minutes via password reset; the credential buyer is locked out within one license renewal cycle (30–48 hours maximum).

Further reading

  • Adhikari V. et al.: “BOLA: Near-Optimal Bitrate Adaptation for Online Videos” (IEEE INFOCOM 2016) — the ABR algorithm paper that underpins segment quality selection in DASH players.
  • Netflix Tech Blog: “Optimized Shot-Based Encodes: Now Playing Everywhere on Netflix” (2018) — describes the evolution from per-title encoding to shot-based (per-scene) optimization, reducing bandwidth a further 20% over per-title Consistent Encoding.
  • Netflix Tech Blog: “Open Connect Everywhere: A Glimpse at the Netflix Streaming Network” — the primary technical reference for OCA appliance design, ISP partnership model, and the content pre-positioning algorithm.
  • Bell R. and Koren Y.: “Lessons from the Netflix Prize Challenge” (ACM SIGKDD Explorations, 2007) — the foundational paper on matrix factorization for collaborative filtering; the ALS approach described here is still the backbone of Netflix’s candidate generation.
  • Netflix Tech Blog: “Chaos Engineering Upgraded” — describes the evolution from Chaos Monkey to the full Simian Army (Chaos Kong, Latency Monkey, Conformity Monkey) and Netflix’s internal experimentation framework for running chaos experiments safely in production.
  • Huang T. et al.: “CONFUSED: Detecting Large-Scale Flipping Attacks on Netflix” (USENIX Security 2022) — documents how Netflix detects coordinated credential abuse at scale using network-graph anomaly detection.