Netflix Business Context & Data Engineering Role Questions
Understanding Netflix's business model, product strategy, and organizational context, with a focus on the Data Engineering role. Covers how Netflix operates in streaming, content recommendations, data platforms, and data engineering responsibilities, including data pipelines, platform architecture, and how business goals drive data work within Netflix.
EasyTechnical
37 practiced
Name key privacy and compliance constraints (for example GDPR, CCPA) that affect how Netflix collects, stores, and uses user data. As an AI Engineer, how would you implement data minimization, access control, and auditability in ML pipelines?
Sample Answer
Key legal constraints- GDPR (EU): lawful basis & consent, purpose limitation, data minimization, storage limitation, right to access/rectification/erasure, data portability, DPIAs for high-risk processing, requirement for pseudonymization & breach notification.- CCPA/CPRA (California): consumer right to know/opt-out/sell, deletion, data minimization, obligations for service providers and contractors.- Other regional laws (LGPD, PIPEDA) and industry-specific rules (COPPA) may add constraints (children's data, cross‑border transfer rules like SCCs/EDPB guidance).How I’d implement controls in ML pipelines (AI Engineer)Data minimization- Ingest: collect only fields required for model purpose; enforce schema at ingestion with required/optional flags and consent metadata.- Transform: strip or tokenise PII (hashing with salt, reversible tokenization only when needed), use pseudonymization.- Modeling: prefer aggregate features, embeddings, or synthetic data; employ differential privacy (DP-SGD) or federated learning when appropriate to limit per-user signal.- Retention: automated lifecycle policies that delete or archive training data after retention window tied to purpose.Access control- Principle of least privilege: role-based and attribute-based access (RBAC/ABAC) for data stores, model weights, and training jobs.- Network & key controls: VPCs, private subnets, KMS-managed encryption keys with key rotation and split-key escrow for sensitive datasets.- Separate environments: isolated dev/test/prod with masked datasets in non-prod; require approval workflows for unmasking.Auditability & compliance evidence- Data lineage & provenance: track dataset versions, transformations, and training runs (e.g., MLflow, Data Catalog) with immutable identifiers.- Immutable audit logs: append-only logs (cloud audit logs or write-once storage) of accesses, model evaluations, and data exports; sign logs or use tamper-evident storage.- Consent & DPIA records: attach consent status and legal basis to each record; log DPIA outcomes and mitigation controls.- Monitoring & alerting: detect anomalous data exfiltration or model drift that may imply privacy risk.- Operational processes: scheduled audits, periodic re-training reviews, and automated documentation exports to demonstrate compliance.Concrete examples- Before training a recommendation model, run a pipeline step that removes emails/SSNs, replaces user_id with salted hash, records consent_flag per row, trains with DP-SGD, stores artifact in encrypted model registry, and logs the training run and access events to an immutable audit trail.This combination ensures models are built from the minimal necessary data, only accessible by authorized actors, and fully auditable to satisfy GDPR/CCPA obligations.
MediumSystem Design
41 practiced
Design a data pipeline to ingest and process 1 billion playback events per day into features used for offline training and for a near-real-time ranking feature with 30-minute freshness. Include components (ingest, stream/batch processing, storage formats), approximate throughput expectations, and failure-handling strategies.
Sample Answer
Requirements & constraints:- Ingest ~1B playback events/day (~1e9/86400 ≈ 11.6k events/sec average). Allow bursts, assume 3x peak ≈ 35k e/s. Event size ~500B–1KB → avg throughput ~6–36 MB/s.- Outputs: (a) offline features for model training (daily/weekly full refresh), (b) near‑real‑time ranking features with ≤30min freshness.High-level pipeline:1. Ingest- Clients produce JSON/Avro events to Kafka (or cloud pub/sub). Use schema registry (Avro/Protobuf) for forward/backward compatibility.- Kafka sizing: aim for ~50 partitions (ceil to allow parallelism) per topic initially; add brokers to support ~200–500 MB/s headroom. Use compression (snappy) to lower network IO.2. Stream processing (near‑real‑time features)- Use Apache Flink (or Structured Streaming with Spark) consuming Kafka with event-time processing, watermarks, windowing (session/user windows).- Maintain stateful aggregations (counts, rolling CTRs, recency metrics) with RocksDB state backend and checkpointing for exactly-once semantics.- Emit feature vectors every minute or on update to a feature serving store.3. Batch processing (offline training features)- Raw events stored in object store (S3/GCS) in daily/hourly partitions as compressed Parquet (columnar), partitioned by date, region, event_type.- Run Spark jobs (EMR, Dataproc) to compute heavy aggregations, historical windows, and labels; write results as Parquet/TFRecord to training bucket and to feature store.4. Feature store & serving- Central feature store (Feast or internal): offline store (Parquet/bigquery) and online store (Redis/KeyDB/RocksDB in a replicated cluster).- Stream job writes/upserts real‑time features into online store. Batch jobs materialize backfills and coordinate with feature registry.5. Model consumption- Training: read parquet/TFRecord from offline store; use distributed training on GPUs.- Serving: ranking service queries online store; if miss, fall back to cached offline feature snapshot.Throughput expectations & capacity:- Kafka: provision for ~50k e/s, retention 7 days (for replay). Brokers sized for storage and network (e.g., 6–8 m5.large-equivalent nodes depending on cloud).- Flink cluster: workers scaled for state size and event throughput; e.g., 8–16 task managers with sufficient memory for RocksDB.- Redis cluster: sharded to support read/write QPS from ranking service; aim for sub-ms reads; provision durable replicas and persistence (AOF/RDB).Failure handling & reliability:- End-to-end exactly-once where possible: Kafka transactions + Flink checkpoints or Spark Structured Streaming with idempotent sinks.- Schema evolution via registry to prevent consumer breaks.- Backpressure: stream jobs tuned with async I/O and proper watermarking; Kafka retention plus replay capability to reprocess after failures.- Checkpointing & durable storage: periodic checkpoints to object store; state snapshots.- Reprocessing strategy: raw events immutable in S3 + partitioned layout enable re-runs for bug fixes or new features.- Monitoring & Alerts: broker lag, processing latency, checkpoint age, online-store miss-rate; automated alerts and runbooks.- Data quality: validator job in stream (drop/route bad records to DLQ) and periodic sampling tests.Tradeoffs & notes:- Flink gives lower latency and weaker operational overhead for stateful exactly‑once; Spark simplifies batch/analytics if team already uses it.- Parquet + partitioning minimizes cost for ML training; TFRecord helpful for TF pipelines.- Freshness vs cost: 30-min freshness achievable with minute-level stream updates; cost dominated by online-store writes and stateful streaming.This design balances durability, reprocessability for ML experiments, and 30‑minute online freshness with scalable components (Kafka → Flink → Feature Store + S3/Parquet for batch).
EasyTechnical
40 practiced
Describe the difference between batch/offline training and online/streaming feature computation at Netflix. Give three examples of features that should be computed near-real-time and three that can be computed in batch, explaining why.
Sample Answer
Batch/offline training and feature computation: compute features periodically over large historical data, store them in feature stores, and use them for model training or inference with higher latency tolerance. Advantages: stability, consistent labels, cheaper compute. Online/streaming (near‑real‑time) computes features continuously from event streams (Kafka, Kinesis) so models see up‑to‑date user state; required for low-latency personalization and rapid adaptation.Three features that should be computed near‑real‑time:1. Current playback state (is_watching, position, bitrate): affects immediate UX and recommendations (resume, bitrate adaptation); stale values break functionality.2. Recent short‑term engagement (last_5min_views, recent_click_rate): captures ephemeral tastes or session intent for next-up suggestions — needs low latency.3. Active device/context (device_type, connectivity, locale changes): used to select encodings, UI, or regional content; must reflect current session.Three features suitable for batch:1. Long‑term genre affinity (genre_histogram_90d): stable preference aggregated over weeks — computed daily.2. Lifetime statistics (total_watch_hours, avg_session_length_month): expensive aggregates with low volatility; safe to compute offline.3. Model training labels and heavy aggregations (churn_score_from_monthly_cohorts, collaborative embeddings updated nightly): costly to compute and need consistency across training examples.Tradeoffs: near‑real‑time increases cost/complexity and eventual consistency concerns; batch offers reproducibility but can miss fast signals. Hybrid approach (store real‑time deltas + batch baseline) is often best.
MediumTechnical
49 practiced
Write a Python function signature and describe the core logic to validate batches of incoming events against an Avro-like schema. The function should reject or repair malformed records and emit validation metrics to a monitoring system. Discuss performance considerations for 10k events/sec ingestion.
Sample Answer
Function signature and high-level logic:def validate_batch(records: List[Dict], schema: Dict, repair_rules: Optional[Dict]=None, emit_metric: Callable[[str, float], None]=None) -> Tuple[List[Dict], List[Dict]]: """ Validate & optionally repair a batch of records against an Avro-like schema. Returns (accepted_records, rejected_records_with_reasons). """Core logic (step-by-step):- Compile schema into fast validators once (e.g., jsonschema or compiled Avro resolver).- For each batch: - Pre-allocate output lists; capture start timestamp. - Vectorized/pass-through checks: required fields, types, enums, nullability, nested records. - For failures apply repair_rules in order (coerce types, default fill, truncate strings, timestamp parsing). Track whether repair succeeded. - If repaired and passes validation, mark accepted; else add to rejected with reason and original payload. - Emit metrics per batch: total, accepted, repaired, rejected, avg_latency_ms, validation_errors_by_type using emit_metric.- Return accepted and rejected lists for downstream processing.Example helper sketch:Performance considerations for 10k events/sec:- Compile schema once; avoid per-record parsing/regex.- Use batch/ vectorized operations where possible (e.g., pandas for column ops) to reduce Python overhead.- Use worker pools (multiprocessing or async I/O with uvloop) sized to CPU and GIL characteristics; prefer multiprocessing for CPU-bound validation.- Keep repair rules simple and deterministic; avoid heavy regex or NLP ops inline.- Backpressure: accept from Kafka/Kinesis with consumer lag control and bounded queue between validator and downstream.- Memory: limit batch size (e.g., 500–2k) to balance latency and throughput; reuse buffers to avoid GC churn.- Observability: emit per-batch and aggregated metrics, histogram of validation latency, and sampling of rejected records (not all) to storage for debugging.- Test under load with realistic payloads and profile hot paths; iterate (JIT: pypy or cythonize if needed).
python
python
def validate_batch(records, schema, repair_rules=None, emit_metric=None):
validator = compile_schema(schema) # precompiled outside hot loop in real system
accepted, rejected = [], []
counts = {"total":0,"accepted":0,"repaired":0,"rejected":0}
start = time.time()
for r in records:
counts["total"] += 1
errors = validator.validate(r) # returns list of error objects
if not errors:
accepted.append(r); counts["accepted"] += 1; continue
repaired = try_repair(r, errors, repair_rules)
if repaired and not validator.validate(repaired):
rejected.append({"record": r, "errors": errors}); counts["rejected"] += 1
else:
accepted.append(repaired); counts["repaired"] += 1
latency = (time.time()-start)*1000
if emit_metric:
emit_metric("validation.total", counts["total"])
emit_metric("validation.accepted", counts["accepted"])
emit_metric("validation.repaired", counts["repaired"])
emit_metric("validation.rejected", counts["rejected"])
emit_metric("validation.latency_ms", latency)
return accepted, rejectedHardTechnical
46 practiced
You inherit a critical production pipeline that intermittently drops events under load and causes undercounting of playback metrics. Describe a structured incident response: immediate mitigations, root-cause investigation steps, short-term fixes to prevent recurrence, and a long-term redesign to avoid similar capacity issues.
Sample Answer
Immediate mitigations- Activate incident war room, notify stakeholders (SRE, product, data teams) and set a communication cadence.- Switch pipeline to degraded but safe mode: divert non-critical traffic to a buffering tier (S3/Kinesis) and reduce ingress via adaptive rate-limiting so critical events are processed.- Turn on verbose metrics/logging and enable sampling of dropped events (store raw payloads) for forensic analysis.- If possible, enable consumer autoscaling or add temporary workers to reduce backlog.Root-cause investigation steps- Collect timelines: correlate ingestion rate, CPU/GPU, memory, queue lengths, GC/IO spikes, and deployment events.- Inspect broker/queue metrics (Kafka/Kinesis): partition lag, throttling, ISR changes, broker GC, network errors.- Trace individual event paths using distributed tracing (trace IDs) to find where events are dropped: producer, broker, consumer, or sink.- Review application logs for exceptions, timeouts, backpressure signals, and OOMs. Check circuit-breaker and retry behavior.- Reproduce load in a sandbox with traffic replay to isolate the failure mode (e.g., consumer can't keep up under bursts, ack loss, or blocked thread pools).Short-term fixes to prevent recurrence- Add durable buffering between stages (partitioned S3 or durable queue) to decouple producers from consumers.- Implement backpressure and explicit rate-limits at producer side and exponential backoff with capped retries.- Make processing idempotent and add at-least-once delivery guarantees with transparent deduplication.- Autoscale consumers and increase consumer parallelism/configs (fetch sizes, batch windows) after load testing.- Improve observability: add SLA alerts on queue lag, error rates, and sampling of dropped events.Long-term redesign- Move to a resilient, decoupled architecture: durable event store (Kafka with adequate partitions and retention or cloud streaming) as source of truth; stateless, horizontally scalable consumers with checkpointing.- Design for backpressure: use flow-control protocols and token-bucket rate adaptation across services.- Capacity planning: define peak, sustained, and burst profiles; run chaos and load testing, and maintain runbooks with scaling knobs.- Ensure schema-versioned events, strong contracts, and observability (end-to-end tracing, business-level metrics that reconcile events to playback counts).- Consider rewriting hot-path components to async, GPU-friendly batch processing for ML inference with bounded latency, and use circuit breakers + graceful degradation to preserve correctness of metrics.What I’d deliver first: a prioritized remediation plan (short-term mitigations + 30/90-day redesign milestones), concrete SLOs and alerts, and a tested replayable buffer so playback metrics can be reconciled without data loss.
Unlock Full Question Bank
Get access to hundreds of Netflix Business Context & Data Engineering Role interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.