0Pricing
Redis Caching & Messaging (Pub/Sub, Streams) · Lesson

Presence and Online Status Tracking

Build a real-time presence system that tracks which users are online using Redis sets, TTLs, and Pub/Sub heartbeats.

What Is Presence?

Presence is the real-time indication of whether a user is online, away, or offline. Chat apps, collaborative editors, and games all rely on it. Redis is ideal because presence data is ephemeral and high-churn.

The Naive Approach

A first idea: store a flag per user. The problem is detecting when someone disconnects ungracefully (closed laptop, lost network). A stale flag would mark them online forever.

SET presence:user:42 online

All lessons in this course

  1. Pattern Matching Subscriptions
  2. Designing Real-time Chat
  3. Event-Driven Architecture
  4. Presence and Online Status Tracking
← Back to Redis Caching & Messaging (Pub/Sub, Streams)