Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Feature Store Design

Overview

A feature store is a centralized system for storing, managing, and serving ML features. It solves training-serving skew, enables feature reuse, and ensures point-in-time correctness. Designing a feature store involves trade-offs between latency, consistency, cost, and complexity.

Architecture

graph TD
    subgraph Offline
        A[Batch Data Sources] --> B[Feature Engineering]
        B --> C[Offline Store Parquet/DW]
        C --> D[Training Data]
    end
    subgraph Online
        E[Streaming Data] --> F[Feature Transformation]
        F --> G[Online Store Redis/DynamoDB]
        G --> H[Real-time Serving]
    end
    B --> F
    I[Feature Registry] --> B
    I --> F

Key Design Decisions

Storage Layer

ComponentTechnologyLatencyCost
Offline StoreParquet/S3, BigQuerySecondsLow
Online StoreRedis, DynamoDBMillisecondsHigh
Feature RegistryPostgreSQL, APIN/ALow

Feature Freshness

FreshnessMethodUse Case
HoursBatch jobsUser aggregate stats
MinutesMicro-batchRecent activity
SecondsStreaming (Kafka)Real-time features
MillisecondsOn-demand computationDerived features

Interview Questions

  1. Design a feature store for a recommendation system — Offline store for user/item historical features, online store for real-time features (recent clicks), feature registry for versioning, and point-in-time joins for training data.

  2. How do you ensure point-in-time correctness? — When creating training data, join features as of the prediction timestamp, not the current timestamp. Use event_time columns and temporal joins.

  3. Online vs offline feature serving? — Offline: batch queries on historical data for training. Online: low-latency lookups for real-time inference. Many features are computed offline and loaded into the online store.

Summary

A feature store design must balance latency, freshness, cost, and consistency. The dual online/offline architecture serves both training and serving needs. Point-in-time correctness is critical for preventing data leakage.

Cross-References