Real-Time Personalization Engines with Stream Processing
Real-time personalization tailors user experiences based on behavior happening right now — not yesterday's batch data. A streaming database continuously computes user profiles, interest scores, and segment assignments from live event streams, serving personalized content via PostgreSQL queries.
Real-Time User Profiles
-- Live user behavior profile
CREATE MATERIALIZED VIEW user_profiles AS
SELECT user_id,
COUNT(*) FILTER (WHERE ts > NOW()-INTERVAL '30 minutes') as actions_30min,
array_agg(DISTINCT category) FILTER (WHERE ts > NOW()-INTERVAL '1 hour') as interests_1h,
SUM(CASE WHEN action='purchase' THEN amount ELSE 0 END) as spend_today,
MAX(ts) as last_active,
CASE
WHEN COUNT(*) FILTER (WHERE ts > NOW()-INTERVAL '5 minutes') > 10 THEN 'highly_engaged'
WHEN COUNT(*) FILTER (WHERE ts > NOW()-INTERVAL '30 minutes') > 5 THEN 'active'
ELSE 'browsing'
END as engagement_level
FROM user_events GROUP BY user_id;
API queries the view:
SELECT interests_1h, engagement_level, spend_today
FROM user_profiles WHERE user_id = 'user_123';
Results personalize content, offers, and recommendations in real time.
Batch vs Real-Time Personalization
| Approach | Freshness | Use Case |
| Batch (daily profiles) | Hours old | Email campaigns, weekly recommendations |
| Real-time (streaming profiles) | Sub-second | In-session personalization, dynamic pricing |
Frequently Asked Questions
Why not just use a recommendation API like Algolia?
Recommendation APIs are great for product search. Streaming personalization is about understanding user behavior in the current session — engagement level, browsing patterns, purchase intent — and adapting the experience in real time.
How do I serve personalized content?
Query user profiles from your application backend via PostgreSQL. RisingWave returns the latest profile within milliseconds. Use the profile data to select content, adjust pricing, or trigger offers.

