Inferensys

Glossary

On-Demand Features

Feature values computed at request time using raw data passed directly to the feature store, useful for context that cannot be pre-computed.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
Real-Time Feature Computation

What is On-Demand Features?

On-demand features are machine learning feature values computed at the moment of a prediction request, using raw data passed directly to the feature store, rather than being pre-computed and stored.

On-demand features are feature values calculated synchronously during an online inference request. Unlike pre-materialized batch or streaming features, they are not stored in the online store. Instead, the feature serving infrastructure executes a user-defined transformation function at query time, using raw request payload data—such as a user's current GPS coordinates or a product SKU—to generate the feature vector immediately. This mechanism is critical for incorporating real-time, non-historical context that cannot be pre-computed.

This approach is essential for high-cardinality or ephemeral context, like calculating the real-time distance to a store or applying a cryptographic hash to a session ID. By shifting computation to the Serving API, on-demand features eliminate the storage cost and staleness risk associated with materializing every possible value. However, they introduce additional inference latency, requiring careful optimization of the transformation logic to meet strict service-level objectives.

Real-Time Computation

Key Characteristics of On-Demand Features

On-demand features are computed at the moment of inference using raw data passed directly to the feature store, enabling personalization on context that cannot be pre-materialized.

01

Request-Time Computation

Unlike pre-computed features that are materialized and stored, on-demand features execute transformation logic synchronously during the prediction request. The raw input data—such as a user's current session ID, geolocation coordinates, or real-time device context—is passed to the feature store, which applies the defined transformation and returns the computed feature vector immediately. This ensures the model always acts on fresh, context-specific data that would be impossible or impractical to pre-calculate for every possible input combination.

02

Stateless Transformation Functions

On-demand features rely on pure, stateless functions that take raw request data as input and return deterministic feature values. These functions are typically defined in Python or SQL and registered in the feature registry alongside pre-computed features. Key properties include:

  • Idempotency: The same input always yields the same output
  • No side effects: Functions do not write to external state
  • Lightweight execution: Designed to complete in single-digit milliseconds to avoid adding latency to the inference path
03

Hybrid Feature Retrieval

A single inference request typically combines both pre-computed and on-demand features into a unified feature vector. The online store retrieves pre-materialized features—such as historical purchase aggregates or long-term preference embeddings—while simultaneously executing on-demand transformations for real-time context. The feature store's serving API orchestrates this parallel retrieval and computation, merging results before delivering the complete vector to the model endpoint.

04

Contextual Input Sources

On-demand features ingest data from the live request payload rather than historical data warehouses. Common input sources include:

  • HTTP request headers: Device type, browser, IP-derived location
  • Session metadata: Current page URL, time on site, scroll depth
  • Real-time sensor data: GPS coordinates, accelerometer readings
  • User-supplied parameters: Search query text, filter selections This architecture enables personalization based on immediate situational context that has no persistent historical record.
05

Cold Start Mitigation

On-demand features are a critical tool for addressing the cold start problem in personalization systems. When a new user arrives with no historical interaction data, pre-computed features return null or default values. On-demand features compensate by extracting predictive signals from the current session context—such as referral source, landing page category, or device type—allowing the model to make informed predictions from the very first interaction without waiting for behavioral history to accumulate.

06

Latency Budget Considerations

While on-demand features provide maximum freshness, they consume a portion of the end-to-end inference latency budget. Best practices include:

  • Capping transformation complexity: Avoid heavy computation or external API calls
  • Leveraging feature caches: Cache results for identical inputs within a time window
  • Monitoring P99 latency: Track on-demand computation time separately from retrieval time Architects must balance the value of real-time context against the strict latency SLAs required for user-facing personalization.
ON-DEMAND FEATURES

Frequently Asked Questions

Clear answers to common questions about computing feature values at request time for real-time machine learning inference.

On-demand features are machine learning feature values computed at the moment of a prediction request using raw data passed directly to the feature store, rather than being pre-computed and stored in advance. When a model serving endpoint calls the Serving API, the feature store executes a user-defined transformation function—such as a Python UDF or lambda—on the fly, using context like the user's current GPS coordinates, session metadata, or real-time API responses. This mechanism is essential for context that cannot be pre-materialized because it is unique to each request, such as the distance between a user's live location and a store, or the current time of day encoded as a cyclical feature. The computation typically completes within single-digit milliseconds to avoid violating the latency budget of the online inference pipeline.

FEATURE COMPUTATION STRATEGY

On-Demand vs. Pre-Computed Features

A comparison of feature computation and serving paradigms for real-time machine learning inference.

MetricOn-Demand FeaturesPre-Computed FeaturesHybrid Approach

Computation Timing

At request time

Before request (batch/stream)

Mixed

Latency Profile

Higher (10-100ms+)

Ultra-low (< 5ms)

Low (5-20ms)

Data Freshness

Real-time

Stale (depends on materialization)

Configurable

Requires Online Store

Handles Contextual Input

Compute Cost at Inference

High

Negligible

Moderate

Storage Overhead

Minimal

High

Moderate

Suitable for Session Data

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.