0
Challenge · 70Services

Realtime: changes, broadcast & presence

Realtimeused in ~70% of apps

You want a comment to appear on DevLog's post the instant someone writes it — no refresh, no polling. The tutorial you find reaches for `postgres_changes`: subscribe to a table, done in four lines. It works perfectly in the demo, on your one browser tab. Supabase's own docs, current as of this course, say verbatim: "we recommend using Broadcast for most use cases." The four-line tutorial teaches you the thing you should stop doing.

Core idea. Realtime is three extensions, not one, and they solve different problems: Postgres Changes streams row changes straight off the WAL but re-checks RLS once per subscriber on every single change, so its cost is (changes × subscribers); Broadcast is a general pub/sub channel whose authorization runs once at channel join and is then cached, so it scales independently of message volume; Presence tracks ephemeral "who's online" state that never touches Postgres at all. "Broadcast from the Database" — a trigger that calls realtime.broadcast_changes() — is the recommended way to stream table changes at any real scale, because it gets Broadcast's cheap authorization while still reacting to your table's writes.
Playground, this isn't a screenshot

RLS is re-checked against the changed row, once per subscriber, on every change.

concurrent subscribers on this topic
RLS evaluations for this one change500

Documented benchmark: a small (Micro) instance with RLS enabled sustains only ~500 concurrent clients at ~30 changes/sec — the RLS-per-subscriber cost is the bottleneck, not bandwidth.

The rule of thumb: more than roughly 3,000 concurrent subscribers on the same changes → reach for Broadcast-from-the-Database. Below that, plain postgres_changes is simpler and fine.
↑ play a little first, then dig in