Persistent Replay & Presence
Goal: Understand ephemeral vs persistent state.
Replay: messages that survive restarts
In-memory replay buffers are lost on restart. Redis replay persists them.
import { createReplay } from 'svelte-adapter-uws-extensions/redis';
export const replay = createReplay(redis, { maxPerTopic: 200 }); When a client reconnects, it sends its last sequence number. The replay buffer sends all messages since then - even across restarts.
Presence: who’s online across instances
In-memory presence only sees local connections. Redis presence aggregates across all instances.
import { createPresence } from 'svelte-adapter-uws-extensions/redis';
export const presence = createPresence(redis, {
heartbeatInterval: 15000,
expireAfter: 30000
}); Handles multi-tab dedup - the same user in three tabs shows up once.
When to use which
| Data | Ephemeral (in-memory) | Persistent (Redis) |
|---|---|---|
| Cursor positions | Yes | Only if multi-instance |
| Who’s online | Yes | Yes, for accurate cross-instance counts |
| Message replay | Acceptable for dev | Required for production with restarts |
| Rate limits | Yes | Yes, for distributed enforcement |
Related guides
- Scaling Guide - step-by-step from single instance to distributed
- Scaling and Resilience - when and why you need extensions
- Distributed Pub/Sub - Redis pub/sub setup
- Observability - monitoring and metrics
- Extensions package - full API reference
Was this page helpful?