Design a Feature Store
Build a dual-store feature platform with an offline Hive/Spark store for point-in-time correct training data and a Redis online store for low-latency serving, bridged by a Kafka materialization pipeline.
The problem this solves
The feature store solves the most underappreciated problem in production ML: the gap between the features a model learned on and the features it receives at inference. This gap — training-serving skew — is responsible for more silent ML failures than any model architecture mistake. A feature store enforces consistency by making the offline training data and online serving data read from the same feature definitions, computed by the same logic.
Before feature stores existed at scale, every ML team at a large company built their own feature pipelines. The data science team computed features in a Jupyter notebook using pandas; the engineering team re-implemented the same computation in Java for the serving endpoint. Six months later, someone changed the Java implementation to fix a performance issue but forgot to update the notebook. The model degraded silently — no exception was thrown, no alert fired, accuracy just drifted downward over weeks until a data scientist noticed the offline metrics no longer matched production. Feature stores break this cycle by making the offline and online paths share one artifact: the feature definition.
Clarifying questions
| Question | Ideal Answer | Why It Matters |
|---|---|---|
| What types of features do we need to support? | Batch features (daily aggregations), streaming features (sliding window counts), and request-time features (computed on-the-fly from the current request payload) | Batch features need a scheduled Spark job; streaming features need a Flink pipeline; request-time features need inline computation at the serving layer — these are three different infrastructure paths |
| What are the freshness requirements per feature group? | Batch: daily; streaming: within 30 seconds of the originating event; request-time: computed on every request, always fresh | Freshness requirements determine the storage technology: daily batch can use Hive partitions; 30-second streaming requires Kafka + Flink; request-time features bypass the store entirely |
| How many feature groups and features do we need to support? | ~500 feature groups across 50 teams, ~5,000 individual features | Drives the registry schema design and the number of Redis namespaces; at 5,000 features across 100M entities the memory footprint becomes non-trivial |
| How often do training jobs run? | Daily for most models; some fraud models retrain every 4 hours | Training job frequency determines the offline store access pattern — multiple teams running Spark jobs concurrently against the same Hive partitions requires careful resource isolation |
| What is the online serving latency SLA? | < 10ms p99 for feature retrieval from the online store, measured at the feature server (excluding model inference time) | 10ms p99 at 1M reads/sec mandates Redis with pipelining; it rules out any approach that requires network hops to a slow store for the critical path |
| How do multiple teams access the feature store? | Centralized store with namespace isolation per team — teams own their feature groups, can read any feature group (with ACL), cannot write to another team’s feature group | Multi-tenancy requires ACL enforcement in the registry API and namespace prefixes in Redis keys; a team that corrupts another team’s features is a production incident |
| Are data lineage requirements strict? | Yes — regulatory compliance requires tracking which raw data sources feed each feature, which models consume each feature | Lineage enables impact analysis: if a data source changes schema, we need to know which features break and which models are affected; lineage is the dependency graph from raw source to model |
| How must PII and privacy be handled? | Features derived from PII must be tagged; GDPR opt-out must purge all online features for a given entity and exclude that entity from retraining | Privacy tagging at the feature group level enables bulk purge on opt-out; failure to handle this correctly is a compliance violation |
Functional requirements
- Feature registration: teams define and register feature groups with a schema (name, type, owner, freshness SLA, source query or transformation code); the registry validates the schema and assigns a versioned feature group ID.
- Feature computation: batch pipeline computes daily aggregations from raw data in S3/HDFS and writes to the offline Hive store; streaming pipeline computes windowed aggregations from Kafka events and writes to both the online Redis store and the offline Delta Lake store.
- Online feature serving: serve features at < 10ms p99 latency for a given entity ID and list of feature references; support batch entity lookup for models that score multiple entities per request.
- Training dataset generation: for a given label table (entity_id, event_timestamp, label), generate a point-in-time correct training dataset by joining the correct historical feature values to each label row — the feature value used must be the most recent value available before the label’s event timestamp.
- Feature lineage: for each feature group, record the upstream data sources, the transformation code version, and the downstream models that consume this feature group.
- Feature monitoring: track null rate, mean, standard deviation, p95, and a drift score (e.g., Jensen-Shannon divergence vs. a 7-day baseline) per feature group; alert when metrics cross configured thresholds.
Non-functional requirements
- Online read throughput: 1M feature reads/sec (50K inference RPS × 20 features per request on average).
- Training dataset generation speed: 1 billion label rows with 10 feature groups joined in under 2 hours using a distributed Spark cluster.
- Feature freshness: batch features updated within 1 hour of midnight each day; streaming features within 30 seconds of the originating event; SLA violations must trigger alerts.
- Online store availability: 99.99% uptime — model inference degrades catastrophically without features; features must be served from cache even if the materialization pipeline is temporarily behind.
- Multi-tenancy: 50 teams, 500 feature groups, 5,000 individual features; ACL enforcement so teams can read but not overwrite each other’s feature groups.
- Audit and compliance: every feature read from the online store for a given entity during a compliance-relevant inference must be loggable for audit; PII features tagged and subject to deletion on GDPR opt-out.
API design
Feature Registry (REST):
POST /api/v1/feature-groups
body: {
name: "user_purchase_stats",
owner: "recommendations-team",
description: "7-day and 30-day purchase aggregations per user",
source_type: "BATCH",
freshness_sla: "PT24H",
schema: [
{ name: "7d_purchase_count", type: "INT64", description: "..." },
{ name: "30d_gmv_usd", type: "FLOAT64", description: "..." }
],
source_query: "s3://data-lake/raw/purchases/"
}
→ { feature_group_id: "fg-uuid-001", version: 1 }
GET /api/v1/feature-groups/{name}
→ { feature_group_id, name, owner, schema, source_type,
freshness_sla, lineage: { upstream_sources, downstream_models },
current_version, created_at }
GET /api/v1/feature-groups/{name}/stats
→ { null_rate, mean, stddev, p95, drift_score,
last_materialized_at, entity_count }
Online Serving (gRPC preferred for low-latency binary protocol):
rpc GetFeatures(GetFeaturesRequest) returns (GetFeaturesResponse)
GetFeaturesRequest {
entity_id: string
feature_refs: repeated string // ["user_purchase_stats:7d_purchase_count"]
request_context: map<string, Value> // for request-time features
}
GetFeaturesResponse {
features: map<string, Value>
metadata: { served_at, feature_freshness: map<string, Timestamp> }
}
rpc GetFeaturesBatch(GetFeaturesBatchRequest) returns (GetFeaturesBatchResponse)
GetFeaturesBatchRequest {
entity_ids: repeated string
feature_refs: repeated string
}
GetFeaturesBatchResponse {
results: map<string, FeatureVector> // keyed by entity_id
}
Training Dataset Generation (async REST):
POST /api/v1/training-datasets
body: {
name: "fraud_model_v3_train",
feature_refs: ["user_purchase_stats:7d_purchase_count", "account:days_since_signup"],
label_table: "hive://ml_labels.fraud_labels_2024",
entity_col: "user_id",
timestamp_col: "transaction_time",
date_range: { start: "2024-01-01", end: "2024-12-31" }
}
→ { job_id: "job-uuid-123", status: "PENDING", estimated_duration_minutes: 45 }
GET /api/v1/training-datasets/{job_id}
→ { job_id, status: "RUNNING|SUCCEEDED|FAILED",
output_path: "s3://feature-store/training-datasets/fraud_model_v3_train/",
row_count, duration_seconds }
Data model
CREATE TABLE feature_groups (
group_id UUID PRIMARY KEY,
name VARCHAR(200) UNIQUE NOT NULL,
owner_team VARCHAR(100) NOT NULL,
description TEXT,
source_type VARCHAR(50) NOT NULL,
freshness_sla INTERVAL NOT NULL,
schema_def JSONB NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE TABLE feature_versions (
feature_group_id UUID REFERENCES feature_groups(group_id),
version INT NOT NULL,
transformation TEXT NOT NULL,
deployed_at TIMESTAMPTZ DEFAULT NOW(),
PRIMARY KEY (feature_group_id, version)
);
CREATE TABLE feature_freshness_log (
feature_group_id UUID REFERENCES feature_groups(group_id),
materialized_at TIMESTAMPTZ NOT NULL,
entity_count BIGINT NOT NULL,
pipeline_run_id VARCHAR(100)
);
CREATE TABLE feature_lineage (
feature_group_id UUID REFERENCES feature_groups(group_id),
upstream_source VARCHAR(500) NOT NULL,
source_type VARCHAR(50) NOT NULL,
registered_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE TABLE model_feature_dependencies (
model_id VARCHAR(200) NOT NULL,
model_version INT NOT NULL,
feature_group_id UUID REFERENCES feature_groups(group_id),
registered_at TIMESTAMPTZ DEFAULT NOW(),
PRIMARY KEY (model_id, model_version, feature_group_id)
);
CREATE TABLE gdpr_deleted_entities (
entity_id VARCHAR(200) NOT NULL,
deleted_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
purged_at TIMESTAMPTZ,
PRIMARY KEY (entity_id)
);
Offline store layout (Hive/Delta Lake):
hive://feature_store.user_purchase_stats/
PARTITIONED BY (ds STRING) -- daily partition, e.g. ds='2024-06-15'
STORED AS PARQUET
COLUMNS:
entity_id STRING,
7d_purchase_count BIGINT,
30d_gmv_usd DOUBLE,
updated_at TIMESTAMP
Point-in-time join pattern (pseudo-SQL):
SELECT
labels.entity_id,
labels.event_time,
labels.label,
features.7d_purchase_count,
features.30d_gmv_usd
FROM labels
LEFT JOIN (
SELECT *,
ROW_NUMBER() OVER (
PARTITION BY entity_id
ORDER BY updated_at DESC
) AS rn
FROM hive://feature_store.user_purchase_stats
WHERE updated_at <= labels.event_time
) features
ON labels.entity_id = features.entity_id AND features.rn = 1
Online store layout (Redis):
Key schema: {feature_group_name}:{entity_id}
Data type: Redis HASH
Example:
HGETALL "user_purchase_stats:user_abc123"
→ {
"7d_purchase_count": "12",
"30d_gmv_usd": "245.50",
"_updated_at": "2024-06-15T23:45:00Z"
}
HGETALL "account_features:user_abc123"
→ {
"days_since_signup": "180",
"account_tier": "gold",
"_updated_at": "2024-06-15T00:01:00Z"
}
TTL: set per feature group based on freshness_sla (e.g., 25 hours for daily batch features,
10 minutes for 5-minute streaming window features)
Architecture diagram
Deep dive: Point-in-time correctness
The classic mistake is joining labels to features using today’s feature values. A model trained on this data sees “future leakage” — also called data leakage or temporal leakage. Consider a concrete fraud detection example: you are training a model to predict whether a transaction at time T was fraudulent. One of your features is account_age_days. If you join today’s account age to a label from 18 months ago, a user whose account is now 3 years old gets credited with 3 years of account age for a transaction they made when the account was only 6 months old. The model learns that old accounts are safer — a true signal — but with wrong magnitudes. Worse, it may learn a spurious correlation: account age at training time correlates with whether the account was eventually flagged (closed, suspended) because only problematic accounts were flagged by the time you assembled the training set.
Point-in-time join: for each training label (entity_id, event_timestamp), retrieve the most recent feature value where feature_updated_at <= event_timestamp. This is a range join — for each label row, scan backwards in feature history until you find the snapshot that was live at the time the event occurred.
Implementation with Spark:
from pyspark.sql import functions as F
from pyspark.sql.window import Window
def point_in_time_join(labels_df, features_df, entity_col, timestamp_col):
joined = labels_df.join(
features_df,
on=[entity_col],
how="left"
).filter(
features_df["updated_at"] <= labels_df[timestamp_col]
)
w = Window.partitionBy(entity_col, timestamp_col).orderBy(
F.col("updated_at").desc()
)
return joined.withColumn("rank", F.rank().over(w)) \
.filter(F.col("rank") == 1) \
.drop("rank", "updated_at")
Performance considerations for point-in-time joins at scale
Naive join is O(N × M) where N is the number of labels and M is the number of feature history rows. At 1 billion labels and a feature table with 365 daily snapshots per entity, this is 365 billion comparisons — completely infeasible without optimization.
Three optimizations bring this to tractable runtime:
First, partition pruning by date bucket. The feature table is partitioned by ds (date string). The Spark planner can push the updated_at <= event_timestamp filter into a partition predicate: for a label with event_timestamp = 2024-06-15T09:00:00, only partitions with ds <= '2024-06-15' are scanned. If the label set spans 1 year, you scan at most 365 partitions rather than all historical partitions.
Second, broadcast join for small feature tables. A feature table with 10 columns for 1 million entities at a single daily snapshot is approximately 10M rows × 100 bytes = 1 GB. Spark can broadcast this to all worker nodes, eliminating the shuffle entirely. Use spark.sql.autoBroadcastJoinThreshold or an explicit broadcast() hint for feature groups with low cardinality.
Third, date-bucketed range join. Instead of a pure range join, bucket both the labels and features by date floor. Labels and features that fall in the same daily bucket join first; then for labels that had no feature update on their exact date, look back one bucket. This reduces the cross-product dramatically.
Deep dive: Online store design
The online store has hard requirements: < 10ms p99 latency, 1M reads/sec, 100 GB dataset. This rules out any approach that involves disk seeks on the critical path. Redis is the natural choice.
Redis data structure per entity
HASH user_purchase_stats:{entityId}
7d_purchase_count → "12"
30d_gmv_usd → "245.50"
_updated_at → "2024-06-15T23:45:00Z"
HASH account_features:{entityId}
days_since_signup → "180"
account_tier → "gold"
is_verified → "true"
_updated_at → "2024-06-15T00:01:00Z"
HASH session_features:{entityId}
recent_categories → "[\"electronics\",\"books\"]"
last_search_query → "wireless headphones"
_updated_at → "2024-06-15T14:22:00Z"
Batched retrieval with Redis pipelining
For a request needing 20 features across 3 feature groups, the naive approach makes 3 separate network round-trips. With Redis pipelining, all 3 HGETALL (or targeted HMGET) commands are sent in a single network write and the responses read in a single network read. This reduces latency from 3 × RTT to 1 × RTT + processing_time. At 10ms p99, RTT alone between services in the same region is typically 0.5–2ms, so batching saves 1–4ms per request.
Sharding strategy
Consistent hashing by entity_id across 10 Redis primary nodes. Redis Cluster handles this natively using hash slots (16,384 slots distributed across nodes). Each primary has 2 read replicas for high availability. Total cluster: 30 nodes.
For multi-tenant isolation, namespace prefixes prevent collisions: {team}:{feature_group}:{entity_id}. A key for the recommendations team’s purchase stats for user abc123 becomes rec:user_purchase_stats:abc123.
Hot entity problem
In recommendation systems, a small number of entities receive disproportionate traffic — a celebrity user’s profile in a social network, a trending item in an e-commerce catalog. Consistent hashing maps all reads for a given entity to the same Redis shard, which can become a hot spot at 1M total RPS if the top 100 entities account for 10% of traffic: that is 100K RPS to a single node, well above its throughput ceiling.
Mitigation: local in-process LRU + TTL cache at the feature server layer. The feature server process maintains a TTLCache (e.g., Caffeine in Java, cachetools.TTLCache in Python) for the top 0.1% hot entities with a 1-second TTL. For features with 30-second freshness SLA, 1-second staleness is acceptable. This absorbs the hot reads before they reach Redis entirely.
Deep dive: Streaming feature computation
Streaming features require sub-minute freshness — they cannot wait for a daily Spark batch. Examples: “number of failed login attempts in the last 5 minutes” (fraud), “items viewed in the current session” (recommendations), “number of rides completed today” (driver incentives). These are computed over a continuous event stream with sliding or tumbling time windows.
Flink pipeline topology
Kafka topic: user-events
schema: { user_id, event_type, timestamp, properties: {} }
Flink Job: streaming-feature-computer
Source: KafkaSource keyed by user_id
Operations:
1. Filter: route event_type to the appropriate window operators
2. KeyedProcessFunction: sliding window (5-min) for LOGIN_FAIL counts
3. KeyedProcessFunction: session window (30-min inactivity gap) for page views
4. Output: FeatureUpdate { entity_id, feature_group, features, updated_at }
Sink 1: Kafka topic feature-updates (for downstream consumers)
Sink 2: Redis Cluster (online store, direct write)
Sink 3: Delta Lake (offline store, micro-batch write every 60 seconds)
Late data handling
Events sometimes arrive out of order — a mobile client may buffer events during a network outage and flush them minutes later. Flink handles this with watermarks: the job advances its notion of “current time” by the maximum event timestamp seen minus an allowed lateness of 2 minutes. Events that arrive within 2 minutes of being “late” still update the window state. Events that arrive beyond the allowed lateness are routed to a side output for audit logging but do not update the current window.
For the offline store, late data is handled naturally: the Delta Lake sink receives all updates with their actual updated_at timestamps, and the point-in-time join uses those timestamps correctly. If a feature update arrives late, the offline history gains a new entry with a past timestamp — which will be picked up by future training jobs that span that time period.
Exactly-once semantics
The Flink job uses Kafka transactional producers for the feature-updates sink and Redis transactions (MULTI/EXEC) for the Redis sink. With checkpointing enabled (every 30 seconds), Flink guarantees exactly-once processing from Kafka source to Kafka sink. For Redis, exactly-once is approximated via idempotent writes: writing the same feature value with the same updated_at timestamp twice has the same effect as writing it once — the Redis hash value is overwritten to the same data.
Python integration — Part A: FeatureServer
import redis
import json
import time
import logging
from typing import List, Dict, Any
from cachetools import LRUCache, TTLCache
logger = logging.getLogger(__name__)
class FeatureServer:
def __init__(self, redis_cluster: redis.RedisCluster,
hot_cache_size: int = 10_000, hot_cache_ttl: int = 1):
self.redis = redis_cluster
self.hot_cache = TTLCache(maxsize=hot_cache_size, ttl=hot_cache_ttl)
def get_features(self, entity_id: str,
feature_refs: List[str]) -> Dict[str, Any]:
cache_key = f"{entity_id}:{','.join(sorted(feature_refs))}"
if cache_key in self.hot_cache:
return self.hot_cache[cache_key]
groups = {}
for ref in feature_refs:
group, feature = ref.split(":")
groups.setdefault(group, []).append(feature)
result = {}
with self.redis.pipeline() as pipe:
keys = []
for group, features in groups.items():
redis_key = f"{group}:{entity_id}"
keys.append((group, features, redis_key))
pipe.hmget(redis_key, features)
responses = pipe.execute()
for (group, features, _), values in zip(keys, responses):
for feat, val in zip(features, values):
ref = f"{group}:{feat}"
if val is not None:
try:
result[ref] = json.loads(val)
except (json.JSONDecodeError, TypeError):
result[ref] = val.decode() if isinstance(val, bytes) else val
else:
result[ref] = None
missing = [ref for ref, v in result.items() if v is None]
if missing:
logger.warning("Missing features for entity %s: %s", entity_id, missing)
self.hot_cache[cache_key] = result
return result
def get_features_batch(self, entity_ids: List[str],
feature_refs: List[str]) -> Dict[str, Dict]:
return {eid: self.get_features(eid, feature_refs) for eid in entity_ids}
Python integration — Part B: FeatureMaterializationWriter
from kafka import KafkaConsumer
import redis
import json
import logging
from datetime import datetime
logger = logging.getLogger(__name__)
class FeatureMaterializationWriter:
"""Consumes feature-updates Kafka topic and writes to Redis online store."""
def __init__(self, consumer: KafkaConsumer,
redis_cluster: redis.RedisCluster, ttl_seconds: int = 604800):
self.consumer = consumer
self.redis = redis_cluster
self.ttl = ttl_seconds
def run(self):
for message in self.consumer:
try:
update = json.loads(message.value)
self._write_feature_update(update)
except Exception as e:
logger.error("Materialization failed for message offset %d: %s",
message.offset, e)
def _write_feature_update(self, update: dict):
entity_id = update["entity_id"]
group = update["feature_group"]
features = update["features"]
updated_at = update["updated_at"]
redis_key = f"{group}:{entity_id}"
mapping = {
feat: json.dumps(val) if not isinstance(val, str) else val
for feat, val in features.items()
}
mapping["_updated_at"] = str(updated_at)
with self.redis.pipeline() as pipe:
pipe.hset(redis_key, mapping=mapping)
pipe.expire(redis_key, self.ttl)
pipe.execute()
logger.debug("Materialized %d features for entity %s in group %s",
len(features), entity_id, group)
Feature monitoring and drift detection
A feature store without monitoring is a silent failure waiting to happen. Features drift when their upstream data sources change — a new logging format drops a field, a schema migration changes a column’s data type, a data pipeline outage stops writing events. Without monitoring, the model silently degrades.
Metrics to track per feature group:
The monitoring job runs after each materialization and computes summary statistics by scanning the most recently written partition:
- Null rate: fraction of entities with a null value for this feature. A sudden spike in null rate indicates a broken upstream pipeline.
- Mean and standard deviation: track how the distribution of feature values shifts over time. A feature whose mean changes by more than 3 standard deviations from its 7-day baseline triggers a drift alert.
- p95 and p99: track the tail behavior. A feature that suddenly has a much higher p99 often indicates outlier injection — e.g., a bug that computes extremely large values for a subset of entities.
- Jensen-Shannon divergence: compare the current distribution (histogram) to a reference distribution from 7 days ago. A JS divergence above 0.1 is a yellow alert; above 0.3 is red and blocks the next model retraining.
- Freshness:
last_materialized_atcompared toNOW(). IfNOW() - last_materialized_at > freshness_sla, the feature group is stale and the online store may be serving outdated values.
Integration with model serving
The feature server should surface feature freshness in the serving response metadata. Model inference services can inspect feature_freshness in the GetFeaturesResponse and apply a fallback strategy if a feature is stale beyond a configured threshold — for example, substituting the global mean for a numerical feature rather than serving a value that was computed 3 days ago.
Feature Store Architecture Patterns
| Approach | Point-in-Time Correct | Streaming Support | Ops Burden | Multi-team Governance | Cost |
|---|---|---|---|---|---|
| No feature store (ad hoc notebooks + hand-rolled serving) | No — each team implements joins differently, leakage is common | Manual, per-team implementation with no shared infra | Low initially, high at scale (each team reinvents the wheel) | None — no shared catalog, no ACL enforcement, feature definitions drift | Low upfront, very high at scale in eng-hours and incident cost |
| Feast (open-source, self-hosted) | Yes — core feature of Feast’s training dataset generation | Yes — Feast supports Kafka and Kinesis sources with push API | Medium — teams manage their own Feast deployment, upgrades, and backend infra (Redis, BigQuery, Snowflake) | Registry is shared but governance is lightweight — no built-in approval workflows | Low licensing cost, moderate infra cost, high ops engineering cost |
| Tecton (managed SaaS) | Yes — point-in-time joins are a first-class abstraction | Yes — native Flink and Spark Streaming backends managed by Tecton | Low — Tecton manages the compute, storage, and pipeline orchestration; teams write feature definitions | Strong — role-based access, feature group ownership, dependency tracking built in | High SaaS licensing cost (1M+/yr at scale), low ops burden |
| Custom in-house (this design) | Yes — full control over join semantics and partition strategy | Yes — full control over Flink topology, watermarks, late data | High — your team owns every layer from Redis sharding to Spark jobs | Strong with investment — you build the registry, ACL, lineage graph yourself | Medium infra cost, high engineering investment to build and maintain |
A data scientist deleted a feature group that a production model depends on. How do you prevent this?
This is a classic dependency graph problem. The naive feature store has no protection: a team can call DELETE /api/v1/feature-groups/user_purchase_stats and the endpoint happily removes the registry entry and stops materialization. The online store TTLs expire within hours. Production models that depend on user_purchase_stats now receive all-null feature vectors, and the model’s behavior degrades silently (null inputs are often treated as 0 or ignored, depending on the model framework).
The fix is a two-part system: soft deletes with dependency blocking.
First, build and maintain a dependency graph in the registry. Every time a model is registered (or retrained), it declares the feature groups it depends on — stored in the model_feature_dependencies table. The registry maintains a reverse index: for each feature group, which models currently depend on it.
Second, change the deletion endpoint to a deprecation endpoint. DELETE /api/v1/feature-groups/{name} is rejected with HTTP 409 if any row exists in model_feature_dependencies with status = 'DEPLOYED' for this feature group. The API response includes the list of dependent models: { "error": "Cannot delete feature group with active model dependencies", "dependent_models": ["fraud_model_v3", "chargeback_scorer_v2"] }. The only allowed action is POST /api/v1/feature-groups/{name}/deprecate, which marks the group as deprecated, prevents new model registrations from depending on it, and sends a notification to all current dependent model owners. Hard deletion is only allowed after all dependent models have been retrained to no longer reference this feature group and marked as RETIRED.
Additionally, the deletion permission should be gated behind a role that requires approval from the feature group’s owner. An automated protection that can be bypassed by a sufficiently senior person is less safe than a protection that requires two parties to agree.
How would you handle a user who opts out of data processing under GDPR's right to erasure?
GDPR Article 17 gives data subjects the right to erasure — the right to be forgotten. For a feature store, this means that all derived features for that entity must be purged from both the online and offline stores, and the entity must be excluded from future model retraining. This is harder than it sounds because the offline store is an immutable, append-only Hive/Delta Lake table — you cannot simply delete a row from a partitioned Parquet file.
The handling proceeds in four phases:
Phase 1: Immediate online store purge. On receipt of a verified opt-out request, immediately delete all Redis keys for the entity across all feature groups. This is fast: issue a DEL command for *:{entity_id} keys across all namespaces. Because Redis Cluster does not support cross-slot key scanning efficiently, maintain a secondary index mapping each entity to the set of feature groups it has data in — this allows targeted key deletion without a full scan.
Phase 2: Short-circuit at the feature server. Insert the entity into the gdpr_deleted_entities table with purged_at = NULL. The feature server checks this table (or a local in-memory cache of it, refreshed every 60 seconds) for every request. If the entity is in the deleted set, return null values for all features immediately without hitting Redis. This prevents serving stale data that somehow survived the Redis deletion.
Phase 3: Scheduled offline store purge. The offline store (Hive/Delta Lake) purge is scheduled within 30 days as required by GDPR. The purge job rewrites affected Hive partitions using Spark, filtering out all rows where entity_id = '{purged_entity}'. Delta Lake’s DELETE DML makes this cleaner — you issue DELETE FROM feature_store.user_purchase_stats WHERE entity_id = '...' and Delta Lake handles the rewrite. Set purged_at in gdpr_deleted_entities when the offline purge completes.
Phase 4: Exclude from retraining. The training dataset generation API checks gdpr_deleted_entities and adds a filter to exclude any entity in the deleted set from the point-in-time join output. This ensures deleted entities never appear in future training data, even from historical partitions that have not yet been physically purged.
Your feature store needs to serve 10M RPS during an e-commerce flash sale. Redis can't handle this at single-digit nodes.
A flash sale concentrates extreme traffic on a small set of entities — the sale items and the users most likely to buy them. At 10M RPS, a 10-node Redis Cluster receives 1M RPS per node on average, but popular item features may concentrate 10–100× that on a single node. Standard Redis Cluster read replicas do not help here because reads go to primaries by default in Redis Cluster mode.
The scaling strategy operates in four layers, each providing an order of magnitude of relief:
Layer 1: In-process cache at the feature server. The feature server runs in many instances across the serving fleet. Each instance maintains a local Caffeine (Java) or cachetools.TTLCache (Python) cache with a 500ms TTL. For features with 30-second freshness SLA, 500ms staleness is completely acceptable. Popular flash sale items appear in nearly every request — after the first cache miss, subsequent requests for that entity’s features within the 500ms window are served from local memory at nanosecond latency. This absorbs 80–90% of reads for the top 1% of hot entities before they reach Redis.
Layer 2: Redis read replicas. Configure Redis Cluster with READONLY commands routed to replicas. The Redis client (e.g., redis-py with read_from_replicas=True) distributes read commands across both primaries and replicas. With 2 replicas per primary, effective read throughput triples.
Layer 3: Pre-materialization before the sale. Flash sales are scheduled events. In the hours before a sale starts, run a pre-materialization job that computes features for all expected high-traffic entities (the sale catalog items, the top-spending user segments) and writes them to Redis. This ensures all hot entities are in the cache when traffic spikes, eliminating the cold-start cache miss storm at sale start.
Layer 4: Fail-open to stale cached values for non-critical features. Designate features by criticality: safety-critical features (those that gate a purchase, detect fraud, or enforce rate limits) must always be fresh; quality features (personalization, ranking boosts) can tolerate extended staleness during peak load. During a detected overload event (Redis latency p99 exceeds threshold), the feature server switches to a degraded mode where quality features are served from the local cache regardless of TTL, and only safety-critical features hit Redis. The model continues running with slightly degraded personalization rather than timing out entirely.
Further reading
The modern feature store has its roots in Uber’s Michelangelo platform, described in their 2017 engineering blog post — Michelangelo was the first industry-scale feature store, introducing the concept of a unified platform where offline and online feature computation were governed by shared feature definitions. Airbnb’s Zipline followed in 2018, building on Scala and Apache Flink to support streaming features at Airbnb’s scale with first-class support for temporal accuracy. LinkedIn open-sourced Feathr in 2022, which brought a Python-first declarative API for defining features and integrated with Azure Machine Learning, Databricks, and Redis. The Feast open-source project (originally from Gojek, now stewarded by the community) provides a vendor-neutral feature store that integrates with BigQuery, Snowflake, Redis, and DynamoDB — it is the most widely deployed self-hosted feature store as of 2024. On the managed SaaS side, Tecton offers an enterprise feature platform with native streaming support, monitoring, and governance that abstracts away the infrastructure complexity in exchange for licensing cost. For a thorough treatment of the feature engineering problem in the broader context of ML systems, Chapter 5 of Chip Huyen’s O’Reilly book “Designing Machine Learning Systems” covers feature engineering, training-serving skew, and feature stores with practical examples drawn from production deployments.