What is Cabby?
Cabby is a real-time server. It holds the WebSocket and Server-Sent Events connections of your app's clients, so your app doesn't have to, and delivers your app's broadcasts to them. It's one binary, written in Rust, and released under the MIT license.
It speaks four protocols:
- Action Cable, compatible with the open-source AnyCable server: the same client libraries, the same RPC contract with your app and the same flags.
- Pusher, so Laravel Echo and
pusher-jsconnect as they are. - Server-Sent Events, for clients that only listen.
- Durable Streams, for reading a stream over plain HTTP from a given position, with long-polling or SSE for what comes next.
Why a separate server
With Action Cable, every WebSocket lives inside your web processes. Each open connection holds memory there, and each broadcast is encoded and sent by the same processes that answer your web requests. Cabby takes that work out of them:
- Your app runs only when something happens. Cabby calls it when a client connects, subscribes or sends a message. Idle connections cost it nothing.
- Deploys don't drop connections. Cabby runs apart from your app, so restarting your web processes leaves every client connected.
- A slow client doesn't pile up messages. If a client stops reading and doesn't take what Cabby writes to it in time, Cabby disconnects it instead of queuing messages for it without end. The other clients aren't affected.
How it fits into your app
- Connect. A client opens a connection to Cabby. Cabby asks your app who it is, over HTTP or gRPC (RPC), or checks a JWT your app issued, without calling your app.
- Subscribe. For each channel, Cabby asks your app again, or checks a stream name your app signed with the shared secret. Turbo Streams can work this way (Hotwire).
- Broadcast. Your app sends each message once: over HTTP, or through Redis, NATS or PostgreSQL. Cabby delivers it to every subscriber.
- Reconnect. With a broker turned on, Cabby keeps the recent history of each stream and the state of each session. A client that reconnects gets its session back and the messages it missed. The client has to ask for them: it sends its previous session and the position it reached in each stream.
By default a broker keeps the last 100 messages of each stream for 5 minutes, and a session for 5 minutes after its client leaves. Configuration lists the settings.
What you get
- One server, nothing else to run. The binary or the Docker image, broadcasts over HTTP, and the SQLite broker for history that survives restarts. No Redis needed.
- Several servers. Redis, PostgreSQL or NATS carry broadcasts between Cabby nodes and keep history and sessions for all of them.
- Presence. Who is in a channel, on a single node.
- Whispers. Clients send short messages, such as "typing…", to the other subscribers of a stream, and Cabby passes them on without calling your app.
- Metrics. Prometheus and StatsD. The Prometheus metrics have AnyCable's names, so existing dashboards keep working.
When to use it
Cabby is worth it when many clients stay connected at once, when clients should catch up after a reconnect, when your backend isn't Rails, or when you run the AnyCable server today and want to swap the binary. The benchmarks compare it with Action Cable, AnyCable and others on the same machine.
A small app with few clients connected at a time, on a single server, is fine with what Rails ships: Action Cable, with Solid Cable or Redis behind it. Add Cabby when the connections start to weigh on your web processes, or when you need history and session recovery.
Next steps
To try it right away, without an app: