How does a feature store work?
- Authors
- Name
- Amit Shekhar
- Published on
A feature store is a central place that stores, manages, and serves features for machine learning, both for training and for live predictions.
In this blog, we will learn about how a feature store works. We will also see the problem before feature stores, how the offline store and the online store serve training and live predictions, the training-serving skew problem, point-in-time correctness, and when to use a feature store.
We will cover the following:
- What is a feature?
- What is a feature store?
- The problem before feature stores
- How a feature store works
- The offline store and the online store
- The training-serving skew problem
- A simple end-to-end example
- Point-in-time correctness
- When to use a feature store
I am Amit Shekhar, Founder @ Outcome School, I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.
I teach AI and Machine Learning at Outcome School.
Let's get started.
What is a feature?
Before we learn about a feature store, we must understand what a feature is.
A feature is a single piece of information about something that we feed into a machine learning model.
Let's say we are building a model to detect if a credit card payment is fraud. The model needs facts about that payment. Each fact is a feature.
Here are a few features for one customer:
- The number of payments made in the last hour.
- The total money spent in the last 7 days.
- The country where the card is being used.
- The average amount spent per payment in the last 30 days.
A machine learning model usually does not read raw data directly. It needs these clean, ready-to-use facts. We have a detailed blog on Feature Engineering that explains how we create such features from raw data.
The subject of a feature can be a customer, a product, a payment, or anything we care about.
Now that we know what a feature is, let's learn what a feature store is.
What is a feature store?
A feature store is a central place that stores, manages, and serves features for machine learning.
It is a special database built only for features.
But it is not just a normal database. A normal database keeps raw data. A feature store keeps the cleaned, ready-to-use features, and it serves them to two very different places.
A feature store sits between our raw data and our machine learning model. It prepares features once and then hands them out whenever they are needed.
The problem before feature stores
To understand why a feature store is so useful, we must first see life without one.
Let's say a company has three teams building three different models.
- Team A builds a fraud detection model.
- Team B builds a model that recommends products.
- Team C builds a model that predicts which customer will leave.
All three teams need a feature like "total money the customer spent in the last 30 days".
The problem is that each team writes its own code to calculate this feature. Team A writes one version. Team B writes a slightly different version. Team C writes yet another version.
This causes three big problems.
Problem 1: Wasted effort. The same feature is built three times. This is repeated work that helps no one.
Problem 2: Different answers. Team A counts only completed payments. Team B also counts refunds. So, the same feature gives different numbers in different teams. This is confusing and error-prone.
Problem 3: A hidden bug. We will explain it fully in the training-serving skew section.
So, here comes the feature store to the rescue.
A feature store lets us build a feature once, store it in one place, and let every team and every model use that exact same feature. This removes the repeated work and the different answers.
Planning your move into AI?
No matter which tech domain you work in today, with your effort, you can transition to these roles:
- AI Engineer
- Forward Deployed Engineer
- AI Agent Engineer
- Harness Engineer
- Voice AI Engineer
- AI Architect
- LLM Engineer
- LLM Inference Engineer
- Gen AI Engineer
- MLOps Engineer
- ML Engineer
- Deep Learning Engineer
Our AI and Machine Learning Program at Outcome School takes you there.
How a feature store works
Now, let's understand how a feature store actually works, step by step.
There are three main stages. We will walk through each one.
Here is the flow:
Raw data
(every payment)
|
↓
+----------------+
| Feature | Stage 1: create the features
| pipeline | (calculate from raw data)
+----------------+
|
↓
+----------------+
| Feature store | Stage 2: store the features
+----------------+
|
↓
Stage 3: serve the features
|
+---+-----------+
| |
↓ ↓
Training Live prediction
(lots of (one customer,
old data) right now, fast)
Here, we can see that raw data goes into a feature pipeline, the result is kept in the feature store, and from there the same features are served to two very different places: training and live prediction.
Stage 1: We create the features.
First, we take our raw data. Raw data is the unprocessed information sitting in our systems, like a long list of every payment ever made.
Then, we write a calculation that turns this raw data into a feature. For example, we group all payments by customer and add them up to get "total spent in the last 30 days".
This calculation is sometimes called a feature pipeline. A pipeline is simply a series of steps that takes raw data in and gives clean features out.
Stage 2: We store the features.
After the features are calculated, we save them inside the feature store. The feature store keeps them organized and labeled, so any team can find and reuse them.
Stage 3: We serve the features.
Serving means giving the features to whoever asks for them. Features are needed in two very different situations.
The first situation is training. Training is when we teach the model using lots of old data. Here, we need millions of past feature values at once.
The second situation is serving a live prediction. This is when a real customer is doing something right now, and we need the model to make a fast decision in milliseconds. We have a detailed blog on Model Serving that explains how a model answers such live requests end to end.
These two situations have completely different needs. Training needs huge amounts of data but can take its time. Live prediction needs very little data but must be extremely fast.
So, how does one feature store handle both needs? The answer is that it uses two separate storage parts inside it.
Let's learn about both.
The offline store and the online store
A feature store usually has two parts. They work together but serve different purposes.
The first part is the offline store.
The offline store keeps a very large history of feature values. It remembers what each feature was at many points in the past.
This store is built to hold a huge amount of data. It is not built for speed. It is built for size.
We use the offline store for training. When we train a model, we pull years of feature history from here. We do not mind if it takes a few minutes, because training itself takes time.
The second part is the online store.
The online store keeps only the latest value of each feature. It does not keep history. It keeps just the freshest number.
This store is built for speed. It can return a feature in a few milliseconds.
We use the online store for live predictions. When a customer makes a payment right now, the fraud model asks the online store for that customer's latest features, gets them instantly, and makes a fast decision.
Let me tabulate the differences between the offline store and the online store for your better understanding.
| Point | Offline store | Online store |
|---|---|---|
| Keeps | Full history of features | Only the latest feature value |
| Built for | Large size | High speed |
| Speed | Slower, takes minutes | Very fast, milliseconds |
| Used for | Training the model | Live predictions |
| Amount of data | Very large | Small per request |
Here, we can see that the two stores have opposite strengths. The offline store is big and slow. The online store is small and fast. Together, they cover both of our needs.
A quick note for you
No matter which tech domain you work in, get familiar with these topics:
- LLM
- RAG
- MCP
- Agent
- Fine-tuning
- Quantization
We put it all together in one video:
AI Engineering Explained: LLM, RAG, MCP, Agent, Fine-Tuning, and Quantization
No need to stop reading - bookmark it and watch later when you get time. Future you will thank you.
Now, let's get back to the topic.
The same feature calculation feeds both stores. We calculate the feature once, and the result goes into both the offline store and the online store. This is how the feature store solves the training-serving skew problem.
Let's see it as below:
One feature calculation
(run only once)
|
+---------+---------+
| |
↓ ↓
+----------------+ +----------------+
| Offline store | | Online store |
| full history | | latest value |
| big and slow | | small and fast |
+----------------+ +----------------+
| |
↓ ↓
Training Live prediction
Here, we can see that one calculation feeds both stores. The offline store keeps the full history for training, and the online store keeps the latest value for live prediction. Because both come from the same calculation, the numbers match.
Let's understand that problem now.
The training-serving skew problem
Training-serving skew is the bug where a feature is calculated one way during training and a different way during live prediction.
So, the model learns from features calculated one way, but at prediction time it gets features calculated a different way. As a result, its predictions become wrong.
Let's see why this happens without a feature store.
When teams train a model, they often use one programming language and one set of tools to prepare features. For example, they prepare features in a large data system using one piece of code.
But when the model goes live and serves real customers, the features are often prepared again, using a different language and different code, because the live system needs to be fast.
Now, even a tiny difference between these two pieces of code creates a mismatch.
Let's say during training, "average spend" is rounded to two decimal places. But during live serving, the new code does not round it. The model was taught on rounded numbers, but now it receives unrounded numbers.
The model behaves badly. Nobody notices for a long time, because the code runs without crashing. It just gives wrong predictions.
So, here comes the feature store to the rescue.
The feature store calculates each feature only once, with one piece of code. That single result is placed into both the offline store, used for training, and the online store, used for live serving.
Because both stores get their values from the same calculation, training and serving use the same feature logic. This removes the most common cause of training-serving skew, and it is one of the main reasons feature stores exist.
To learn Model Development and Training, along with Model Deployment and Serving, check out our AI and Machine Learning Program at Outcome School.
A simple end-to-end example
The best way to learn this is by taking an example. Let's walk through one full story.
Suppose we run an online shopping app, and we want a model that decides whether to show a discount to a customer.
We decide to use one feature: "number of orders the customer placed in the last 30 days".
Step 1: We calculate the feature.
We write one calculation that looks at all orders and counts how many each customer placed in the last 30 days.
For a customer named Riya, the answer is 12 orders.
Step 2: We store the feature.
This value of 12 is saved. It goes into the offline store as part of Riya's history, and it goes into the online store as Riya's latest value.
Step 3: We train the model.
To train, we pull millions of past values from the offline store. The model learns the pattern that customers with many orders respond well to discounts. The model is now trained.
Step 4: We serve a live prediction.
Now, Riya opens the app. We must decide in milliseconds whether to show her a discount.
The live system asks the online store for Riya's feature. The online store instantly returns 12. The model receives 12, the same way it saw such numbers during training, and decides to show a discount.
Here, we can see that the value 12 came from one calculation. Training used it, and live serving used it. There is no mismatch. It works perfectly.
Stay updated: Subscribe to our newsletter to get our latest AI and Machine Learning blogs straight to your inbox.
Point-in-time correctness
Now, let's learn one more important idea.
Point-in-time correctness means that when we train a model on past data, each feature value must be exactly what it was at that moment in the past, and not the value from later.
Let's see why it is important with an example.
Suppose we are training a model to predict fraud for a payment Riya made on 1st January.
To train correctly, we need to know Riya's "total spent in the last 30 days" as it was on 1st January. We must not use the value from 1st March, because on 1st January, that future value did not exist yet.
If we accidentally use the March value, we are teaching the model with information from the future. In real life, the model will never have future information. So, the model will look great during training and then fail badly in the real world.
This mistake is called data leakage. Leakage means future information leaks into the past during training, which is unrealistic.
So, here comes the feature store to the rescue again.
Because the offline store keeps the full history of every feature with timestamps, it can give us the correct value for each exact moment.
So, when we ask for Riya's feature for 1st January, the offline store hands us the 1st January value and nothing from the future.
This careful matching of features to the correct past moment is point-in-time correctness. It keeps our training realistic.
When to use a feature store
Now, let's see when we actually need one.
A feature store is most useful in these situations.
- We have many teams or many models reusing the same features. A feature store stops repeated work and keeps features consistent.
- We need fast live predictions. The online store gives features in milliseconds.
- We train on large amounts of history. The offline store handles huge data with point-in-time correctness.
- We want to avoid training-serving skew. The feature store removes it by using one calculation for both training and serving.
But we do not always need one.
If we have a small project with one model and one person, a feature store can be extra effort that gives little benefit. In that case, simple files or a normal database are enough.
So, we use a feature store when our machine learning work grows large, shared, and needs both speed and consistency.
Now we must have understood how a feature store works, why we need it, and when to use it.
Frequently Asked Questions
Is a feature store the same as a normal database?
No. A feature store is not just a normal database. A normal database keeps raw data, while a feature store keeps the cleaned, ready-to-use features. It also serves those features to two very different places: training, which needs lots of old data, and live prediction, which needs one customer's features right now.
What is a feature pipeline?
A feature pipeline is the calculation that turns raw data into features. It is simply a series of steps that takes raw data in and gives clean features out. For example, it can group all payments by customer and add them up to get "total spent in the last 30 days".
Why does the online store keep only the latest feature value?
The online store keeps only the latest value because it is built for speed. Live predictions need very little data but must be extremely fast, so the online store can return a feature in a few milliseconds. The full history lives in the offline store, which is used for training.
Why is training-serving skew hard to notice?
Training-serving skew is hard to notice because the code runs without crashing. The model simply receives features calculated a different way from the ones it was trained on, so it quietly gives wrong predictions. Even a tiny difference, like rounding a value during training but not during live serving, is enough to cause it.
That's it for now.
Thanks
Amit Shekhar
Founder @ Outcome School
You can connect with me on:
Follow Outcome School on:
