Centrifugo
Language-agnostic real-time messaging (Websocket or SockJS) server.
Alternatives
Tech stack
No tech stack added yet. Sign in to suggest some
Introduction
Centrifugo is an open-source real-time messaging server developed by Centrifugal Labs. You can self-host it as an alternative to solutions such as PubNub, Pusher, Ably, Socket.IO, Phoenix.PubSub and SignalR. It runs as a standalone service that manages persistent connections from a large number of clients and provides a simple publish API. Your application backend only needs to call this API to publish a message, and Centrifugo pushes it in real time to the clients subscribed to the relevant channel. Adopting it does not require changing your existing application architecture. The project has been in development for about ten years and is built on Centrifuge, a Go library. Companies such as VK, Badoo, ManyChat, OpenWeb and Grafana have used it in production.
Key Features
- Multiple transport protocols: supports WebSocket, HTTP-streaming, SSE (Server-Sent Events), WebTransport and gRPC.
- PUB/SUB and state synchronization: provides channel message broadcasting, and can also synchronize state between clients so that it stays eventually consistent with the database.
- Efficient broadcasting: the client protocol can use JSON or binary Protobuf, which suits scenarios where a single message is sent to thousands or even millions of subscribers at once.
- Rich feature set: flexible authentication methods, multiple subscription types, channel history, presence, delta updates, and the ability to proxy connection events to your application backend.
- Official SDKs: official client libraries for web and mobile.
- Horizontal scaling: built-in Redis integration (supporting Redis Cluster as well as compatible stores such as AWS Elasticache, Google Memorystore, DragonflyDB, Valkey and KeyDB), plus PostgreSQL and NATS, to spread connections across multiple nodes. Newer open-source versions can also build a multi-node cluster using only PostgreSQL.
- AI streaming: supports resumable streams, multiple people viewing the same session at once, automatic transport fallback and scaling across nodes, which makes it well suited to pushing an LLM's responses to users token by token.
Performance
The official blog describes a test in which, on hardware roughly equivalent to a single modern server, Centrifugo handled one million WebSocket connections and delivered 30 million messages per minute. Another article describes a test in Kubernetes that reached one million connections and 500,000 messages per second.
Target Users and Use Cases
It suits development teams that need to add real-time features to web or mobile apps. Common use cases include:
- Chat, instant messaging and live comments
- Real-time dashboards, metrics and telemetry display
- State synchronization for multiplayer games
- Financial data such as stock quotes and trading information
- Location tracking for IoT devices and vehicles
- Streaming AI model responses
It doesn't matter if your backend isn't good at handling concurrency, because Centrifugo takes care of the long-lived connections.
Installation and Deployment
You can start it with a single Docker command:
docker run -p 8000:8000 centrifugo/centrifugo:v6 centrifugo
The official documentation describes other installation methods as well. A single-node deployment has no external dependencies. A multi-node deployment requires Redis, PostgreSQL or NATS as a message broker.
Centrifugo PRO
Besides the open-source edition, the project offers Centrifugo PRO, a commercial edition aimed at enterprises. It adds features such as ClickHouse-based analytics, real-time tracing, performance optimizations, a push notification API and SSO integration for the web admin interface, and it comes with priority technical support.
Notable Characteristics
- You host it yourself and your data stays inside your own network. Unlike managed services, there is no billing per message or per token.
- It is language-agnostic: a backend built on any technology stack can publish messages through the API.
- The official documentation is comprehensive, including a complete tutorial on building an instant messaging app from scratch (the Grand tutorial), and the official website has more than 20 demos with source code.
Discover more
AnyCable
Realtime server for reliable two-way communication over WebSockets, Server-sent events, etc.
Artalk
Comment system built in Golang, providing a lightweight and highly customizable solution for adding comments to your website.
Ergo
Modern IRCv3 server written in Go, combining the features of an ircd, a services framework, and a bouncer.
Gotify
Notification server with Android and CLI clients (alternative to PushBullet).
Mattermost
Platform for secure collaboration across the entire software development lifecycle, can be integrated with Gitlab (alternative to Slack).
Rocket.Chat
Teamchat solution similar to Gitter.im or Slack.