Skip to main content
XenonStack

Enterprise AI

XenonStack Blog Real-Time Machine Learning: Architecture and Trade-offs

and | Published | Updated

Real-Time Machine Learning: Architecture and Trade-offs
11:18

Key takeaway

  • Real-time machine learning for enterprise leaders: online prediction, feature stores, continual learning, evaluation, trade-offs and an adoption path.

Real-time machine learning means a model serves predictions from fresh data at the moment of the request and, in its strictest form, also updates itself as new data arrives. Most enterprise systems need only the first part: online prediction with features kept fresh by a streaming pipeline. Continual learning is the harder, rarer step, and it should be earned by evidence, not assumed.

This guide is for CTOs, architects and platform leads who must decide where real-time machine learning pays off and what it demands from the data platform. It covers the machine learning layer. For the Spark and Kafka pipeline underneath it, see our guide to real-time streaming with Apache Spark and Kafka.

What is real-time machine learning?

Chip Huyen, in her widely cited article on the subject, separates two things. Batch prediction precomputes results at fixed intervals, such as every few hours or daily. Online prediction generates results when the request arrives. She argues that batch prediction is not a prerequisite for online prediction. The article also describes stages of maturity, summarised below.

Four maturity levels of real-time machine learning, from batch prediction to continual learning, each paired with the infrastructure it adds.
LevelWhat happensWhat you needWhen it fits
Batch predictionPredictions are precomputed on a scheduleScheduled jobs and a store for resultsResults can be stale for hours; users with history
Online prediction with batch featuresSession activity looks up precomputed embeddings or features at request timeStreaming infrastructure; candidate generation before rankingSession-based recommendations, new or logged-out visitors
Online prediction with online featuresFeatures are computed at request time or by a stream engine seconds beforeStream processing engine, feature store, model store, better development environmentsFraud detection, pricing, estimates that depend on the last few minutes
Continual learningThe model updates on a trigger: time, performance drop or driftTriggers, continual evaluation, an orchestratorOnly where data shifts fast and the update cost is justified

Source: Chip Huyen, Real-time machine learning: challenges and solutions (January 2022, updated January 2023).

When does a business need it, and when does it not?

The test is whether a decision loses value while it waits for the next batch run. Fraud screening, recommendations for visitors with no history and loan or payment decisions are typical cases. Analytical work that feeds people on a human timescale, such as churn analysis, segmentation and sales forecasting, rarely needs it.

Cost can point the same way. As reported by Huyen, Grubhub had about 31 million users in 2020 but only about 2 percent of them logged in on a given day, so her illustration is that precomputing daily predictions for everyone wastes roughly 98 percent of the compute. Online prediction avoids work for inactive users. These are the author's figures for one company; treat them as an illustration, not a benchmark.

What does a real-time ML architecture look like?

The pattern is an event-driven pipeline: events enter a streaming platform, a stream processor turns them into features, a feature store serves those features to the model, and monitoring watches the result. Each layer has a clear job.

LayerJobExample, according to its docs
Event streamingPublish and subscribe to event streams, store them durably, process them as they occur or laterApache Kafka lists these three capabilities on its introduction page
Stream processingCompute windowed features with state and event timeApache Flink describes application state as a first-class citizen, event-time processing with watermarks, and checkpointing that keeps state consistent after failures (Flink applications)
Feature storeServe the same features for training and for online requestsFeast ingests features from batch sources and makes them available online through materialisation (Feast concepts)
Model servingApply the model to the feature vector within the request latency budgetInference endpoint, custom application code or a portable model format
MonitoringTrack feature quality, drift and prediction qualitySee the monitoring and evaluation section below

Huyen separates real-time features, computed at request time and fresh to milliseconds but sensitive to latency, from near-real-time features, precomputed by a stream engine and stale by seconds but off the request path. Choosing between them is a latency and cost decision for each feature, not for the whole system. She also describes "log and wait": reusing the features logged at prediction time to reduce training-serving skew.

Where predictions will also be shown live to users or operators, the display layer has its own design choices, covered in our guide to real-time streaming data visualisation. For the wider decision context, see real-time intelligence.

How are continually learning models trained and evaluated?

Huyen describes four stages of continual learning. The first is manual, stateless retraining from scratch. The second is automated retraining on a schedule, which mainly adds a model store. The third is automated, stateful training, which fine-tunes on new data and needs model lineage and reproducible streaming features. The fourth is continual learning proper, where updates are triggered by time, a performance drop or drift, and which needs triggers, continual evaluation and an orchestrator.

Evaluation changes most. Stationary test sets no longer suffice once a model adapts to a changing environment. The options she lists are backtesting, progressive evaluation, shadow deployment, A/B testing, canary analysis and bandits. Bandits are harder to implement than A/B tests, so they are rarely used outside large technology companies. In one experiment she cites, an A/B test needed over 630,000 samples for a 95 percent confidence interval, while Thompson sampling identified a model that was 5 percent better with under 12,000 samples. Offline model testing still matters before any online rollout; see our guide to machine learning model testing.

What are the trade-offs and risks?

RiskWhy it happensControl
Monitoring overloadModels can have thousands of features and most statistical changes are benign, so the hard part is finding the changes that matterAlert on a short list of features tied to business outcomes; review the rest on a schedule
Training-serving skewFeatures are built one way for training and another in productionOne feature definition for both paths; log features at prediction time
No standard infrastructureOnline training stacks are often built in-house and kept confidential by companies that have themStart with online prediction and scheduled retraining before continual learning
Cost of retrainingStateless daily retraining repeats workConsider stateful training; Huyen reports that Grubhub cut training cost 45 times after the switch in 2021
Unreviewed model changesA model that updates itself changes decisions without a releaseVersion every model, keep rollback, and keep a decision trace for audit

When not to use it: if the business can wait for the next batch run, or if the team has no mature streaming infrastructure, start with batch prediction and add online features for one use case at a time.

Is the DARPA Real Time Machine Learning programme the same thing?

No. DARPA's Real Time Machine Learning (RTML) programme addressed a different problem: ML systems that are trained before deployment and cannot adapt in the field, such as on autonomous vehicles and sensor arrays. According to its page, it worked on hardware generators and compilers that create ML application-specific integrated circuits (ASICs) from high-level source code with no human in the loop, including a compiler from a high-level ML framework to Verilog. The page gives no dates and states that the programme is complete and no longer maintained. See the DARPA RTML page.

How should an enterprise adopt it?

  1. Pick one decision that loses value when it waits, and write down the latency it needs.
  2. Move that model to online prediction with batch features first.
  3. Add online features through a stream processor and a feature store only where the decision needs them.
  4. Add automated retraining with a model store and shadow deployment.
  5. Consider continual learning only if drift is frequent and measured, and keep rollback and audit in place.

Governance runs through every step. ElixirData Context OS keeps governed context, versioned policy and decision traces in one decision layer above AI agents, which is the kind of record a self-updating model needs. Elixir Govern (formerly AgentGRC) keeps autonomous agent actions inside policy, with the audit trail risk teams need.

To map one real-time decision your models make, and the data, features and policy it depends on, book a Context Workshop. See what happens in the workshop.

Frequently asked questions

What is real-time machine learning?

It is a setup where a model produces predictions from fresh data when a request arrives. In its strictest form the model also updates as new data arrives, which is called continual learning. Many production systems need only the first part, online prediction with fresh features.

What is the difference between real-time and batch prediction?

Batch prediction precomputes results at fixed intervals, such as every few hours or daily. Online prediction generates results when the request arrives, which helps with new or logged-out visitors who have no precomputed result. Batch prediction is not a prerequisite for online prediction.

Do I need a feature store for real-time machine learning?

A feature store is one of the listed requirements for online prediction with online features, alongside a stream processing engine and a model store. Feast, for example, makes features from batch sources available online through a process it calls materialisation.

How do you evaluate a model that keeps changing?

A stationary test set no longer suffices once a model adapts to a changing environment. Approaches include backtesting, progressive evaluation, shadow deployment, A/B testing, canary analysis and bandits. Bandits are harder to implement than A/B tests.

Is the DARPA Real Time Machine Learning programme the same thing?

No. DARPA's RTML programme targeted hardware generators and compilers that create ML ASICs from high-level source code. Its page says the programme is complete and no longer maintained. It is a hardware effort, whereas this guide covers the software and data architecture for online prediction.

Follow XenonStack on LinkedIn: XenonStack on LinkedIn for new guides on agentic AI, data and platform engineering.

Ready to put AI agents to work? Explore ElixirClaw, the agentic OS platform to build, orchestrate and govern AI agents.

Table of Contents

navdeep-singh-gill

Navdeep Singh Gill

Global CEO and Founder of XenonStack

LinkedIn profile

Navdeep Singh Gill is serving as Chief Executive Officer and Product Architect at XenonStack. He holds expertise in building SaaS Platform for Decentralised Big Data management and Governance, AI Marketplace for Operationalising and Scaling. His incredible experience in AI Technologies and Big Data Engineering thrills him to write about different use cases and its approach to solutions.

Get the latest articles in your inbox

Subscribe Now

Interested in solving your challenges with the XenonStack team?
Get Started

Tell us about you and your priorities so we can prepare the right conversation. It takes about 2 minutes.

Please Select your Industry
Banking
Fintech
Payment Providers
Wealth Management
Discrete Manufacturing
Semiconductor
Machinery Manufacturing / Automation
Appliances / Electrical / Electronics
Elevator Manufacturing
Defense & Space Manufacturing
Computers & Electronics / Industrial Machinery
Motor Vehicle Manufacturing
Food and Beverages
Distillery & Wines
Beverages
Shipping
Logistics
Mobility (EV / Public Transport)
Energy & Utilities
Hospitality
Digital Gaming Platforms
SportsTech with AI
Public Safety - Explosives
Public Safety - Firefighting
Public Safety - Surveillance
Public Safety - Others
Media Platforms
City Operations
Airlines & Aviation
Defense Warfare & Drones
Robotics Engineering
Drones Manufacturing
AI Labs for Colleges
AI MSP / Quantum / AGI Institutes
Retail Apparel and Fashion

Continue