🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Feature Store Design

AI System DesignFeature ManagementđŸŸĸ Free Lesson

Feature Store Design

Centralized Feature Management for ML Systems

What You'll Learn

  • 1Explain why an online store and an offline store must share one feature definition
  • 2Size an online feature store for memory, QPS, and a latency budget
  • 3Compute staleness from schedule interval, compute time, and sync time
  • 4Prevent training leakage with point-in-time joins and timestamp guards

Why This Matters

Feature stores solve critical challenges in production ML:

  • Feature Reuse: Share features across teams and models
  • Consistency: Same features for training and inference
  • Scalability: Serve millions of feature requests per second
  • Point-in-Time Correctness: Prevent data leakage

â„šī¸

Companies like Uber (Michelangelo), Netflix, and Airbnb have built custom feature stores to manage thousands of features across hundreds of ML models.

What is a Feature Store?

A feature store is a centralized repository for storing, managing, and serving ML features. It provides:

Online Store

  • Low-latency serving (<10ms)
  • Real-time feature retrieval
  • Optimized for inference
  • Redis/DynamoDB

Offline Store

  • Batch feature computation
  • Historical feature retrieval
  • Optimized for training
  • S3/HDFS/Data Lake

Feature Registry

  • Feature metadata
  • Lineage tracking
  • Version management
  • Discovery and search

Feature Store Architecture

Feature Store ArchitectureData Sources- Databases- Event Streams- Data LakesFeature Engineering- Transformations- Aggregations- EmbeddingsFeature Registry- Metadata- Lineage- VersioningOffline Store- S3 / HDFS / Data Lake- Historical Features- Training Data- Point-in-Time JoinsOnline Store- Redis / DynamoDB- Low-Latency Serving- Real-Time Features- <10ms Response TimeFeature Serving API- REST / gRPC- Batch / Real-Time- Feature ValidationML Models- Training Pipeline- Inference Service- A/B TestingMonitoring- Feature Drift- Data Quality- Usage Analytics

Online vs Offline Store

AspectOnline StoreOffline Store
Latency<10msSeconds to minutes
StorageRedis, DynamoDBS3, HDFS, Data Lake
Use CaseReal-time inferenceTraining, batch prediction
Data VolumeHot data onlyComplete history
ConsistencyEventualStrong

Feature Engineering Patterns

Batch Features

Batch feature engineering computes features over historical data using distributed processing frameworks like Spark. Common patterns include daily aggregations (event counts, unique event types, total values), rolling window features (7-day and 30-day aggregates), and item-level features (age in days, popularity scores based on view/like/purchase counts).

Real-Time Features

Real-time feature stores update features as events arrive using in-memory stores like Redis. Features are maintained using hash structures with counters, timestamps, and computed aggregates. TTL (time-to-live) is set to automatically expire old features. Online feature retrieval provides sub-millisecond access for inference.

Point-in-Time Correctness

Point-in-time correctness prevents data leakage by ensuring features are computed using only data available at the time of prediction.

A point-in-time corrector retrieves historical features at specific timestamps for training (using event timestamps to avoid leakage) and retrieves the latest features for online serving. This ensures training data mirrors what the model would have seen at prediction time.

Feast Feature Store Integration

Feast is an open-source feature store that provides a unified interface for defining, storing, and serving features. Key concepts include:

  • Entities: The keys used to look up features (e.g., user_id, item_id)
  • Feature Views: Collections of features computed from data sources
  • On-Demand Features: Features computed at request time
  • Feature Store Operations: Retrieving online features, writing to online stores, and managing feature lifecycles

Feature Groups

Feature groups organize related features together under a common owner and description. They provide logical grouping for feature management, making it easier to discover, maintain, and version related features. Example groups include user engagement metrics and item popularity metrics.

Sizing the Online Store

Online serving capacity is a memory question first. For entities, features each, and bytes per value:

A system with 50 million users, 200 float32 features per user, and bytes needs GB of raw values. Redis adds roughly 100 bytes of per-field overhead for keys, encodings, and expiry, so plan for close to 100 GB resident, which is eight 16 GB primaries plus replicas across three availability zones. Store per-entity hashes rather than one key per feature, or the key count alone pushes past 10 billion strings.

Latency is a cache question. A feature fetch has to fit inside its slice of the model's p99 budget, typically 10 of 100 ms. With a cache hit taking 1 ms and a miss falling through to the warehouse taking 20 ms, expected latency is:

So a 90 percent hit rate buys 2.9 ms on average and keeps the tail inside budget; a hit rate that slips to 50 percent doubles the average and pushes the p99 over even though nothing else changed. Hit rate, not raw Redis speed, is the metric worth alerting on.

Staleness and Freshness Bounds

Staleness is bounded by three terms: the schedule interval, the compute time, and the sync into the online store.

With an hourly batch, 15 minutes of aggregation, and 1 minute to sync results into Redis, the worst case is 76 minutes of staleness and the average is about 46 minutes. Fraud features that must see the last 5 minutes of activity cannot come from this path at all; they need a streaming updater with an interval of 5 seconds, which changes the engineering but not the interface. Declare a freshness SLA per feature group and alert when measured lag exceeds it, because a stalled consumer looks perfectly healthy until models start scoring on day-old behavior.

Point-in-time correctness is the other half of the contract. For entity at label time , the training row must read:

The guard is simple: a row leaks whenever . A nightly job that rebuilds a feature from full history and then joins it to labels from last week silently violates this, inflating offline AUC while the online model performs no better than baseline. Catch it by re-scoring a sample of training rows with a correct as-of join and diffing the values.

Failure Modes Worth Designing For

The online store is a single point of failure for every model behind it. Serve defaults for missing keys instead of erroring, keep a small local cache inside the serving pod to ride out a Redis restart, and shadow-read a sample of requests from the warehouse so silent inconsistency is caught before it becomes an accuracy regression. On the write side, idempotent upserts keyed by entity and event time make replays safe, and a schema registry stops a renamed column from poisoning thousands of features in a single deploy.

Interview Q&A

â„šī¸

Q: How do you handle feature freshness in a feature store?

Answer:

  1. Tiered Freshness: Different features have different freshness requirements

    • Real-time features: <1 minute latency
    • Near real-time: 5-15 minutes latency
    • Batch features: Daily/hourly updates
  2. Streaming Pipeline: Use Kafka/Kinesis for real-time updates

  3. Backfilling: Support historical feature computation

  4. Freshness SLAs: Define and monitor feature freshness guarantees

â„šī¸

Q: How do you prevent data leakage in feature engineering?

Answer:

  1. Point-in-Time Joins: Use event timestamps for feature computation
  2. Feature Timestamps: Track when each feature was computed
  3. Training-Serving Skew Detection: Compare training and serving features
  4. Validation Pipeline: Automated checks for leakage

A leakage detector checks each feature to verify that the feature timestamp does not occur after the label timestamp, flagging any rows where future information may have leaked into training data.

â„šī¸

Q: How do you scale a feature store to handle millions of feature requests per second?

Answer:

StrategyImplementationBenefit
CachingRedis ClusterReduce database load
ShardingPartition by entity IDHorizontal scaling
ReplicationMultiple read replicasHigh availability
CompressionReduce feature sizeLower network overhead
BatchingGroup feature requestsReduce API calls

Common Mistakes

Computing training features from full history and joining them to past labels

Fix: Use an as-of join with event timestamps and reject any row where the feature time is later than the label time.

Treating the online store as a cache with no SLA

Fix: Track hit rate and freshness lag per feature group, since a 50 percent hit rate doubles feature latency.

One feature definition per team with no shared registry

Fix: Register features once with owner, schema, and lineage so training and serving read the same definition.

Best Practices

  • Declare a freshness SLA per feature group and page when measured lag passes it
  • Store per-entity hashes and shard by entity ID so memory and QPS scale together
  • Backfill with the same code path as the online writer, so history and serving values cannot diverge

Key Takeaways

  • Online store memory is U x F x b: 50M users, 200 float32 features, 4 bytes gives 40 GB raw and about 100 GB resident
  • Expected feature latency is h x T_hit + (1 - h) x T_miss, so 90 percent cache hits gives 2.9 ms and 50 percent blows the budget
  • Staleness bound is interval plus compute plus sync: 60 + 15 + 1 = 76 minutes worst case on hourly batches
  • A training row leaks whenever the feature timestamp is later than the label timestamp, which inflates offline AUC only

Frequently Asked Questions

Do I need both an online and an offline store?

Yes, because they answer different questions. The offline store holds full history for training joins and backfills, where scan throughput matters and seconds of latency are fine. The online store holds only the latest value per entity, sized for millions of reads per second at 1 to 10 ms. They share feature definitions and write paths; duplicating the definitions is what creates training-serving skew.

How do I know when a feature is too stale for my model?

Measure how much signal lives in the recent window. If a fraud model uses a count of transactions in the last 30 minutes and your pipeline refreshes hourly, that feature is noise: up to 76 minutes of lag means the count is wrong for most of its own window. Give it a streaming updater or drop it, and keep slow-changing features like tenure or account age on the batch path.

What happens when the online store goes down?

Design the answer before it happens. Serving pods should fall back to local cached values, then to defaults for missing keys, and the request should still return a prediction rather than an error. Pair that with a circuit breaker so you do not hammer a recovering cluster, and shadow-read a sample of traffic from the warehouse afterward to confirm the values still match.

Interview Questions

Q1: How do you size an online feature store for 50 million users and 200 features?

Raw memory is 50M x 200 x 4 bytes = 40 GB; with about 100 bytes of Redis overhead per field, budget near 100 GB resident, so eight 16 GB primaries with replicas across three zones. Then check QPS: at 10,000 requests per second each fetching 20 features, you issue 200,000 Redis ops per second, which needs sharding by entity ID rather than a single node.

Q2: How do you prevent data leakage in a feature pipeline?

Every training row is built with an as-of join: for label time t, take the latest feature value with event time less than or equal to t. Enforce it in code with an assertion that feature time never exceeds label time, and audit by re-scoring a sample of rows with a correct join and diffing values.

Q3: Batch and streaming both update the same feature. How do you keep them consistent?

Make the streaming path the low-latency writer and the batch path the reconciler: the nightly job recomputes authoritative values and overwrites, which repairs any drift the stream introduced. Key writes by entity and event time so replays are idempotent, and alert when the two paths disagree on a sampled entity.

Quiz

Next Steps

  • Module 4: Model Serving Architecture - Learn to serve models with features
  • Module 5: Real-Time ML Inference - Deep dive into low-latency serving
  • Practice: Design a feature store for a recommendation system

Continue to Model Serving Architecture ->

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-07

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert AI System Design Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement