Loading…
Supabase Realtime, with Multiplayer Features
SupabaseWen Bo Xie
Summary
Supabase announced the third major release of Supabase Realtime, evolving the system from a single-tenant PostgreSQL change listener into a multi-tenant, distributed real-time platform. Built using Elixir and the Phoenix framework across a distributed node cluster, the new architecture decouples the database listener into an extension model and opens generic WebSocket functionality. New multiplayer capabilities include Presence, which uses Conflict-free Replicated Data Types (CRDTs) to track user connection states, and Broadcast, which distributes ephemeral messages across topics without writing to disk. The modular extension design allows listening to multiple PostgreSQL instances, external systems like MySQL, and financial or blockchain feeds, as demonstrated on a globally distributed 20-node cluster.
Context
Prior versions of Supabase Realtime were single-tenant and could only poll one PostgreSQL database at a time via Write-Ahead Log streaming, restricting WebSocket usage strictly to database change propagation.
Approach / What changed
Supabase re-architected Realtime into a multi-tenant distributed cluster built on Elixir and Phoenix, decoupling PostgreSQL listening into an extension architecture and introducing general WebSocket features including CRDT-based Presence and ephemeral Broadcast messaging.
Takeaways
- Realtime v3 introduces multi-tenancy on a distributed Elixir and Phoenix cluster, enabling a single deployment to listen to multiple databases while improving fault tolerance and resource utilization.
- Presence automatically tracks user connections and synchronizes online states across distributed cluster nodes using Conflict-free Replicated Data Types (CRDTs).
- Decoupling database listening into an extension architecture allows general WebSocket pub/sub broadcasting and opens support for external data sources such as MySQL, financial tickers, or blockchains.
Related reading
Supabase ·
Realtime Postgres RLS now available on Supabase
Supabase updated its Realtime server to enforce PostgreSQL Row Level Security (RLS) policies when broadcasting database changes over websockets. Previously, Realtime operated as an opt-in beta feature that sent all replication changes to every client regardless of user authorization. To enforce RLS per subscriber without heavy performance overhead, Supabase introduced WALRUS, a security engine colocated inside PostgreSQL. For each replication change, WALRUS looks up active subscribers, assumes their identities, and evaluates row visibility using prepared statements queried by primary key. This in-database evaluation avoids external network round trips and single-query planning overhead while returning an authorized subscriber list to Realtime.
Oliver RiceSupabase ·
Supabase Beta March 2022
Supabase announced several major platform updates for March 2022, introducing global edge deployments for JavaScript and TypeScript functions developed and tested locally. Database querying expanded to support GraphQL through an open-source, portable Postgres extension. Supabase Realtime received support for multiplayer and presence to enable collaborative applications, alongside enterprise and scale capabilities including Point-In-Time-Recovery, SLAs, premium support, a Prometheus endpoint, and an observability dashboard. To enhance security, an integration with GitHub secret scanning automatically notifies developers and rolls exposed service_role keys found in public repositories. Additional updates include the PostgREST 10 pre-release, Next-JS auth helpers, new OAuth providers, and full remote hiring across engineering, marketing, and human resources.