Feature Stores Basics (Feast)
Serve consistent online/offline features and reduce training-serving skew.
In plain words
A feature store is a shared place that keeps the numbers your models use, in one agreed form, so that training and live predictions see the same thing.
Think of it like…
A shared pantry with a labelled inventory. Cooks (models) get the same ingredient prepared the same way whether they are planning next month's menu (training) or cooking tonight (serving); the pantry also records when each batch was prepared so nobody cooks with ingredients that didn't exist yet.
Where you’ve seen it
A churn model uses features such as orders_30d, avg_basket_value and days_since_last_login, keyed by customer_id. For training, a label table lists (customer_id, event_timestamp, churned). Point-in-time correctness: for a label at January 10, the feature values on record are January 5 → 3 orders, January 9 → 4 orders and January 12 → 7 orders; get_historical_features joins the latest value at or before the label time, giving 4 and never the January 12 value of 7, which would leak the future into training. Skew appears when logic differs: offline, orders_30d counted 30 calendar days; online, a hand-written query counted 4 weeks (28 days), so average values differed by roughly 7% and model scores shifted; defining the feature once in a feature view removes the second implementation. Serving: the prediction API calls store.get_online_features(features=[...], entity_rows=[{"customer_id": 1042}]) and receives values from Redis in a few milliseconds (p99 around 5 ms), whereas recomputing from raw orders takes about 300 ms. Materialisation runs every 15 minutes with materialize_incremental, so online values can be up to 15 minutes stale; each feature view has a TTL (for example 2 days) so very old values are treated as missing. Memory sizing: 10 million customers × 20 features × 8 bytes = 1.6 GB of raw values, so plan Redis for roughly 3 to 5 GB including key and structure overhead. The team defines three shared feature views used by the churn, upsell and fraud models, so the 20-feature definition is written and tested once, and a data-quality check blocks materialisation if the null rate on any feature jumps. They decided against a feature store for a one-off monthly batch model with a single consumer, where a tested SQL view was simpler.
Words you’ll hear
- Entity
- The key a feature describes, such as customer_id.
- Feature view
- A named group of features with a source, schema and TTL.
- Point-in-time join
- Joining each label to the feature values known at that moment, never later ones.
- Materialisation
- Copying the latest feature values from the offline to the online store.
Visual diagram
Theory & deep dive
Concepts and point-in-time correctness
In Feast an entity (customer, product) is the join key; a data source points to a table or file with an event timestamp; a feature view groups features computed from one source with a schema and a TTL (how long a value stays valid); and a registry stores these definitions. For training you provide an entity dataframe of keys and event timestamps (the label times) and call store.get_historical_features(entity_df, features). For each row Feast finds, per feature view, the latest value at or before that timestamp (within the TTL). With values January 5 → 3, January 9 → 4 and January 12 → 7 and a label on January 10, the joined value is 4. A naive join on the latest value overall would use 7, which wasn't known on January 10 and silently inflates validation scores.
Point-in-time joins also handle late-arriving data carefully: if a value was recorded on January 11 but describes January 9, use the timestamp at which it became available to the system (a created_timestamp) if you want to model what could have been known. Without a feature store you can implement the same logic with SQL window joins (ASOF joins), but each team must do it correctly every time, which is where bugs creep in.
Label: customer 1042, event_timestamp Jan 10. Feature history for orders_30d: Jan 5 = 3, Jan 9 = 4, Jan 12 = 7. As-of join → 4. Joining on the latest overall → 7 (leak). A label on Jan 13 would get 7.
Online serving, freshness and when to adopt a feature store
Materialisation moves the latest values from the offline store into the online store (feast materialize-incremental <end_date>, run by a scheduler). Prediction services then call get_online_features with entity keys and get values in single-digit milliseconds, compared with about 300 ms to recompute from raw events. Freshness equals the materialisation interval: every 15 minutes means values up to 15 minutes old, so choose intervals by how fast features change and how much staleness the model tolerates; streaming ingestion exists for second-level freshness. Size memory from entities × features × bytes: 10 million customers × 20 features × 8 bytes = 1.6 GB raw, which with key overhead means planning 3 to 5 GB. Set TTLs so stale values are treated as missing rather than silently used, and decide how the model handles missing features (the same imputation as in training).
Adopt a feature store when several models share features, when you need online features with consistent definitions or when point-in-time correctness is hard to guarantee otherwise. Skip it for a single batch model with a tested SQL pipeline: it adds infrastructure, governance and learning cost. Whatever you choose, apply the same disciplines: one definition per feature with an owner and description, data-quality checks (null rate, ranges, freshness) before materialising, monitoring of online/offline consistency (sample entities and compare values from both stores) and versioning of feature definitions so a model records which versions it was trained on.
10,000,000 customers × 20 features × 8 bytes = 1.6 GB of raw values. Redis keys, hashes and overhead typically double or triple that: plan 3–5 GB. Materialising every 15 minutes bounds staleness at 15 minutes; a 2-day TTL treats anything older as missing.
How it works, step by step
Step 1 of 41. Define entities and feature views
Declare entities, sources with event timestamps and feature views with schemas and TTLs; review them like code.
- Owner
- per feature view
When to use it & trade-offs
What it is
A feature store manages the features that models consume so that training and serving use the same definitions. It has an offline store (a warehouse or Parquet files) holding historical feature values for training and batch scoring, an online store (Redis, DynamoDB or similar) holding the latest values for millisecond lookups at prediction time, a registry of feature definitions and a materialisation process that copies fresh values from offline to online. Feast is a widely used open-source example: you declare entities (the keys, such as customer_id), data sources, and feature views (features with a schema and a TTL), then call get_historical_features for training sets with point-in-time correct joins and get_online_features at serving time.
Why it matters: The hardest bugs in production ML are not in the algorithm but in the data: a feature computed one way in a notebook and another way in the service (training-serving skew), a training set built with values that weren't yet known at prediction time (leakage) and the same logic reimplemented by every team. A feature store centralises definitions, guarantees point-in-time correctness and provides low-latency access, at the cost of extra infrastructure that only pays off when several models share features or online serving needs them.
When to reach for it
- Several models reusing the same customer features
- Real-time predictions needing aggregated history
- Teams that must prove training data had no future information
When to avoid or be careful
- A feature store for one monthly batch model
- Different definitions of the same feature offline and online
- Materialising without data-quality checks
Where features come from
Strengths: One definition; point-in-time joins; fast lookups.
Watch out: Extra infrastructure and governance.
Strengths: Simple; uses existing warehouse.
Watch out: Online parity and point-in-time logic are manual.
Strengths: No storage layer.
Watch out: Slow for heavy aggregations; risk of skew.
Interview signals & numbers to know
When this topic comes up
- “What is training-serving skew?”
- Point-in-time correct joins
- Offline versus online stores
- Feature freshness and TTL
- When a feature store is overkill
Benchmarks & rules of thumb
- 4 not 7
- as-of join value for a Jan 10 label in the example
- ≈ 5 ms vs 300 ms
- online lookup versus recomputing from raw events
- 1.6 GB
- 10M entities × 20 features × 8 bytes
Common mistakes & follow-ups
Common interview mistakes
- Joining the latest feature value instead of the value as of the label time.
- Forgetting TTLs, so stale values look current.
- Letting two teams define the same feature differently.
Likely interviewer follow-ups
- How would you detect skew between offline and online features?
- How fresh do your features need to be?
- How would you migrate a feature to a new definition safely?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Feature Stores Basics (Feast) with data science interview Q&A and hands-on practice.