Every durable message is stored and numbered before anyone sees it. Here is the path it takes, and what happens when a client drops and comes back.
The path of a message
Find a relay. A client asks its endpoint's address which relay host to use, over HTTPS. The libraries send your server's HTTP API calls straight to a relay host too; raw HTTP calls can also go through the endpoint.
Connect. The client opens a WebSocket (wss://) straight to that relay host, which checks its token and the endpoint's limits.
Store. A publish is stored in the endpoint's database and numbered before it is acknowledged.
Read. Echo reads each stored message from the database.
Fan out. Echo sends it to every relay host with subscribers on the channel, and each relay host delivers it to its clients.
Swengle's management for the region starts, watches, scales and replaces the hosts. It is not on the message path: if it is briefly down, the endpoint keeps routing clients and messages keep flowing.
When you publish
The database commit comes first. The message gets the channel's next number and is stored; only then is the publish acknowledged. With a replicated database, and on Shared, the replica in another zone confirms it first, and no subscriber sees a message a failover could take back.
Then fan-out. Echo picks up each stored message and sends it once to each relay host with subscribers on its channel. Each subscriber gets the messages of a channel in order.
Retries are safe. A publish retried with the same idempotency key is stored once and returns the original result. The libraries always send a key.
Broadcasts and presence take a shorter path, from relay host to Echo and out again. They are never stored.
When a client reconnects
Every delivered message carries a cursor: its place in the channel. The libraries reconnect on their own, look up a relay host again and rejoin each channel from the last message they delivered.
Replay from the last sequence. The relay host reads what was missed from the database and sends it in order, then carries on live. A message the client may already have seen can arrive again, with the same id.
Or RESYNC_REQUIRED. If every message since the cursor can no longer be sent, for example because the client was away longer than the endpoint keeps messages, it is told so. The library rejoins at the channel's current end and calls your resync handler, where you reload your app's state.
If fan-out is interrupted, relay hosts read new messages from the database instead, so they arrive a few seconds late rather than not at all.
Scaling within a host budget
A Cluster scales itself on load within its Maximum hosts, which you set (6 by default, up to 22). You are billed for the hosts that run, not for the budget.
Relay hosts and Echo hosts are added as they get busy and removed as they get quiet, never beyond the budget.
The database moves to a larger host as its load grows. At the largest size the region offers, with room in the budget, it splits into more databases.
When a relay host leaves, its clients reconnect to the others and resume from their cursors. Nothing acknowledged is lost.
A Dedicated server moves to a larger or smaller size, by you or by automatic scaling on its CPU. Shared scales on its own.
What each plan runs on
Shared
Your endpoint on a shared cluster that Swengle runs, with other customers' endpoints and per-endpoint limits. Replicated across zones, with continuous backups.