Recommendations use case

Recommendation features current to clicks from five minutes ago

Session signals give ranking its strongest context. Batch jobs miss them. Feldera maintains these signals continuously from your event stream.

Build a recommendation pipeline Read the analysis

The problem

Batch misses session context

Features such as "items viewed this session," "category affinity in the last 30 minutes," and "recency-weighted interaction score" need events from the current visit. An hourly batch pipeline cannot compute them.

Hourly refreshes are stale once a session begins. Someone browsing running shoes for 20 minutes before visiting your homepage gets rankings based on features calculated before that session.

This is session blindness: history is present, current behavior is not. Feldera keeps current signals fresh.

Freshness by pipeline

Hourly batch

Session context features
Not computable

Feldera incremental

Session context features
Updated within 100ms of each click
Internal benchmark: session-aware feature staleness
Batch: 38 min avg. Feldera: 90ms avg. Measured on a 20M event/day synthetic click stream.

The solution

Feldera session-aware features

Define session aggregates in standard SQL. Feldera compiles them into an operator graph updated with each click in your stream.

sql
-- recommendation_features.sql

CREATE VIEW session_item_views AS
SELECT
  session_id,
  item_id,
  COUNT(*) AS view_count,
  MAX(event_time) AS last_viewed_at
FROM click_events
WHERE event_time > NOW() - INTERVAL '30 minutes'
GROUP BY session_id, item_id;

CREATE VIEW recency_weighted_affinity AS
SELECT
  user_id,
  category,
  SUM(
    EXP(-EXTRACT(EPOCH FROM (NOW() - event_time)) / 3600)
  ) AS affinity_score
FROM click_events
WHERE event_time > NOW() - INTERVAL '2 hours'
GROUP BY user_id, category;

CREATE VIEW session_category_seq AS
SELECT
  session_id,
  ARRAY_AGG(DISTINCT category) AS categories_visited,
  COUNT(DISTINCT category) AS category_breadth
FROM click_events
WHERE event_time > NOW() - INTERVAL '30 minutes'
GROUP BY session_id;

Available session signals

Batch pipelines cannot express session aggregates because they need the active session's event stream. Feldera makes those signals queryable features.

Recency weights, no re-scan

Feldera maintains exponential recency decay over a 2-hour window incrementally. Each click changes only affected user/category state, not the whole window. Time advances without breaking the calculation.

"Nightly user-level category preferences were reused for 24 hours. The model performed well but stayed stale. With Feldera session-aware features, real-time maintenance we had considered too costly became straightforward incremental SQL. The lift came from freshness, not a model change."

Priya V., ML Engineer, consumer recommendation service

Connect your click stream, define session features in SQL, and serve them to your ranking model. Run locally in under 10 minutes.

Get started

Build with Feldera. Start free.

Incremental. Real-Time. Always Fresh. Real-time AI feature engine for incremental streaming computation.

Start the quickstart Create free account