What You'll Learn
- 1Allocate an end-to-end freshness budget across CDC, ingest, queue, compute, and publish
- 2Size raw and compressed storage for a stated row rate, row width, and replication factor
- 3Formulate point-in-time correct feature lookup so training never reads future data
- 4Choose between full and sampled validation using the measured cost per check
Why This Matters
ML models are only as good as their data. Production ML pipelines must handle petabyte-scale data ingestion, ensure data quality, compute features reliably, and support schema evolution - all while maintaining low latency and high throughput.
The pipeline is also where silent bugs live, because a wrong value is still a valid value. A feature computed with a join against the current table instead of the timestamp-bounded one will look perfectly healthy in every dashboard and will quietly hand the model information it could not have had at decision time. Sizing the pipeline in numbers, rather than adjectives, is what makes those failures reviewable.
System Architecture Overview
Data Pipeline Implementation
ML data pipelines use a schema-driven approach with composable validators and transformers. A pipeline processes batches through validation (enforcing constraints like not-null, range, and set membership), transformation (cleaning, encoding, normalization), and enrichment (adding timestamps and schema version). Stream processors buffer incoming records and flush them in configurable batch sizes for efficient processing.
Data Validation
Data validation enforces expectations on incoming data: not-null checks, range constraints (min/max), and set membership. Each expectation is checked against every record, and records failing any expectation are filtered out. Data profiling generates column-level statistics including dtype, null counts/percentages, unique counts, and for numeric columns: mean, std, min, max, and median.
Feature Store Integration
Feature stores provide dual-storage architecture: an online store (Redis/DynamoDB) for low-latency serving and an offline store (S3/GCS in Parquet) for batch analytics. Features are written to both stores simultaneously with configurable TTL. The online store serves features for real-time inference via multi-key lookups, while the offline store supports point-in-time correct queries for training - joining features computed before each training example's timestamp to prevent training/serving skew.
Interview Q&A
Q1: How do you handle schema evolution in ML pipelines?
Answer: Use a schema registry with backward compatibility rules. For additive changes (new columns), add defaults. For breaking changes, version the schema and maintain both old and new pipelines temporarily. Use Avro/Protobuf with schema evolution support. Implement contract testing between producers and consumers.
Q2: What is point-in-time correct feature computation?
Answer: When computing features for training, you must use only data available at the time of each training example - not future data. Feature stores implement this via time-travel queries: for each entity and timestamp, they join features that were computed before that timestamp. This prevents training/serving skew.
Q3: How do you ensure data quality at scale?
Answer: Implement a layered approach: 1) Ingestion validation (schema, types), 2) Statistical validation (distribution checks, outlier detection), 3) Business rule validation (domain-specific constraints), 4) Freshness monitoring (staleness alerts), 5) Automated profiling with drift detection. Use Great Expectations or Tecton for declarative validation.
Q4: Compare batch vs. streaming for ML features.
Answer: Batch (Spark, dbt): Higher throughput, lower cost, suitable for features that update hourly/daily. Streaming (Flink, Kafka Streams): Lower latency, real-time features, higher cost. Most systems use both: streaming for latency-sensitive features, batch for complex aggregations. Feature stores unify the serving layer.
Q5: How do you handle missing data in production?
Answer: Strategies: 1) Imputation (mean, median, model-based), 2) Default values (domain-appropriate), 3) Missing indicator features (flag missingness), 4) Model-based (models that handle natively like XGBoost). The key is ensuring training imputation matches serving imputation - implement in the feature pipeline, not the model.
Quiz
-
What prevents training/serving skew?
- A) Data augmentation
- B) Point-in-time correct features
- C) Feature normalization
- D) Model regularization
-
Which tool is used for declarative data validation?
- A) Spark
- B) Great Expectations
- C) Redis
- D) Kafka
-
What is CDC in data ingestion?
- A) Change Data Capture
- B) Continuous Data Collection
- C) Cross-Data Center
- D) Cached Data Compression
-
What is the purpose of a feature store?
- A) Store trained models
- B) Serve features with low latency and consistency
- C) Store raw data
- D) Run batch jobs
-
Which is NOT a data quality dimension?
- A) Completeness
- B) Accuracy
- C) Latency
- D) Freshness
Answers: 1-B, 2-B, 3-A, 4-B, 5-C