Aurabase Logo
aurabasedocs
docs›Services›Realtime

Realtime

Self-negotiated WebSocket, SSE and NATS. Presence, replay, guaranteed ordering, backpressure. 1M connections by POP, fanout sub-15ms p99 between regions.

7 min read·Level intermediate·Revised on Apr 15, 2026
This English text was generated automatically from the French original and has not been reviewed yet.
#
Overview

Sync, presence, broadcast

The aura-realtime service broadcasts three types of events: CDC Postgres (INSERT/UPDATE/DELETE filtered by RLS), Presence (which is online) and Broadcast (custom events independent of the database). All go through the same SDK via .channel().

A channel is identified by an arbitrary name (sensors:live, doc:42, room:abc). Messages are ordered by channel, deduplicated by message_id, and guaranteed exactly-once within the same channel.

Info

Subscriptions inherit the RLS policies from the database. A client can only subscribe to changes it can read — the filter is evaluated server-side on the WAL, not client-side.

#
Mental model

One connection, N channels

The SDK maintains a single multiplexed TCP connection between the client and the nearest POP. You can open 100 channels without opening 100 sockets.

schematext
                      ┌──────────────────┐
   Client (WS)  ────▶ │ aura-realtime    │
                      │  ─ CDC listener  │
                      │  ─ Presence CRDT │
                      │  ─ Broadcast hub │
                      └────────┬─────────┘
                               │ NATS JetStream
          ┌────────────────────┴────────────────────┐
          ▼                    ▼                    ▼
    aura-db WAL         Presence state        autres POPs
Astuce

Events are partitioned by consistent hashing. A channel always lives on the same POP, but its replication to other POPs is guaranteed in less than 15ms p99.

#
Primitives

Six native abilities

Three transports

WebSocket first, SSE fallback, inter-service NATS. Self-negotiated.

CDC Postgres

WAL changes filtered on the server side, RLS applied to the flow.

API presence

Who is online, arbitrary state, join/leave events.

Multiplex

1000 channels over 1 TCP connection, zero additional network costs.

Event replay

Replays the last 60 events upon reconnection.

Cursors collab

Native primitive, adaptive throttle 60 FPS, client interpolation.

#
Examples

Four essential patterns

components/LiveDevices.tsxtypescript
const channel = aura.channel('devices:live')
  .on('postgres_changes', {
    event: '*',
    schema: 'public',
    table: 'devices',
    filter: `tenant_id=eq.${tid}`,
  }, ({ new: row }) => render(row))
  .subscribe()
Mandatory cleaning

Always call channel.unsubscribe() on unmount. In React, do this in the useEffect cleanup — the useChannel hook above does it for you.

#
Guarantees

What we promise, what we don't promise

✓ GUARANTEED

  • Ordering by channel
  • Exactly-once per message_id in a channel
  • Fanout p99 < 15ms cross-region
  • Auto reconnection with 60s replay
  • Explicit backpressure (configurable drop policy)

✗ NOT GUARANTEED

  • Cross-channel ordering
  • Exactly-once cross-channel (at-least-once)
  • Sub-ms latency (< 15ms p99 is our floor)
  • Replay beyond 60s (use a Postgres log)
Last updated · Apr 15, 2026