centrifugo README

The project's README from github.com/centrifugal/centrifugo. As one markdown file: README.md.

Centrifugo

Scalable real-time messaging server in a language-agnostic way.

CI Release Docker Pulls License Telegram Discord

Centrifugo is an open-source scalable real-time messaging server. It instantly delivers messages to application online users connected over supported transports (WebSocket, HTTP-streaming, Server-Sent Events (aka EventSource), GRPC, WebTransport). Centrifugo has the concept of channel subscriptions – so it's a user-facing PUB/SUB server.

Centrifugo is language-agnostic and can be used to build chat apps, live comments, multiplayer games, real-time data visualizations, collaborative tools, AI streaming responses, etc. in combination with any backend. It is well suited for modern architectures and allows decoupling the business logic from the real-time transport layer.

The core idea of Centrifugo is simple – it's a PUB/SUB server on top of modern real-time transports:

Centrifugo PUB/SUB diagram

Your backend communicates with Centrifugo over a simple HTTP or GRPC API to publish messages into channels, while clients subscribe to those channels using one of the official SDKs (or the unidirectional approach with no SDK dependency).

Quick start

Spin up Centrifugo with its embedded admin UI using Docker:

docker run -it --rm -p 8000:8000 centrifugo/centrifugo:latest centrifugo \
  --client.insecure --admin.enabled --admin.insecure
# ^ insecure flags: for local trial only, never use in production

Then open http://localhost:8000 to reach the admin UI, where you can watch live connections and publish messages into channels. The insecure flags above remove authentication for a frictionless local trial only – never use them in production.

For native binaries, Homebrew, packages, and production configuration see the installation instructions, and follow the quickstart tutorial to connect your first client.

Why Centrifugo

The hard part is to make the PUB/SUB concept production-ready, efficient, flexible and available from different application environments. Centrifugo is a mature solution that already helped many projects with adding real-time features and scaling towards many concurrent connections. It provides a set of features not available in other open-source solutions in the area:

Client SDKs

Official SDKs wrap Centrifugo's bidirectional protocol and handle reconnects, subscription state, message recovery, and more across platforms:

Platform / Language SDK
JavaScript (browser, Node.js, React Native) centrifuge-js
Dart / Flutter (mobile and web) centrifuge-dart
Swift / native iOS centrifuge-swift
Java (Android, JVM) centrifuge-java
Python (asyncio) centrifuge-python
Go centrifuge-go
.NET / MAUI / Unity [WIP] centrifuge-csharp

For simple use cases Centrifugo also supports a unidirectional approach (WebSocket, SSE, HTTP-streaming, GRPC) that needs no SDK – any standard client for the transport works. See the transports overview and the client protocol spec for details.

Documentation

Community

Found a bug or have an idea? Open an issue. Want to contribute? See CONTRIBUTING.md.

Backing

This repository is hosted by packagecloud.io.

Private NPM registry and Maven, RPM, DEB, PyPi and RubyGem Repository · packagecloud

Also thanks to JetBrains for supporting OSS (most of the code here written in Goland):

JetBrains logo

centrifugo (centrifugal/centrifugo)

Searching Database…

这是什么?Centrifugo 是一个开源、与语言无关的实时消息服务器,任何后端都可以通过 WebSocket、HTTP 流、SSE、GRPC 或 WebTransport 把消息推送给已连接的客户端。它可以作为自托管方案,替代 Pubnub、Pusher、Ably、Socket.IO、Phoenix.PubSub 和 SignalR。
它是我要导入的库,还是独立服务器?它是你自己运行的独立服务器,可以通过 Docker、原生二进制文件或 Homebrew 安装。你的后端通过简单的 HTTP 或 GRPC API 与它通信来发布消息,客户端则使用官方 SDK 订阅频道。
我该怎么把它跑起来?用 Docker 启动带内置管理界面的版本即可在本地试用,然后在浏览器中打开管理界面,查看连接并发布测试消息。若要用于生产环境,请按照快速入门教程,使用原生二进制文件、Homebrew 或带有正式配置的安装包。
运行它需要 Redis 或其他组件吗?单节点可以独立运行,但要跨多个节点扩展,就需要一个消息代理:Redis(或 Redis Cluster,以及 Elasticache、Valkey、KeyDB、DragonflyDB 等兼容存储)、PostgreSQL 或 Nats。
用 Docker 快速开始时有什么需要注意的坑吗?README 中展示的快速启动参数会完全关闭客户端和管理端的身份验证,以便本地演示更顺畅。生产环境中绝不能使用这些不安全的参数。
我必须用 Go 写后端才能使用它吗?不必。Centrifugo 与语言无关,任何后端技术栈都可以通过其 HTTP 或 GRPC API 与它通信。它常被用于构建聊天应用、实时评论、多人游戏、实时仪表盘和 AI 流式回复。
客户端 SDK 支持哪些传输方式?WebSocket、HTTP 流、服务器发送事件(EventSource)、GRPC,以及实验性的 WebTransport。
不安装 SDK 能连接吗?可以。Centrifugo 支持基于 WebSocket、SSE、HTTP 流或 GRPC 的单向方式,无需 SDK,任何支持该传输方式的标准客户端都可以使用。
Centrifugo 如何验证连接?它支持基于 JWT 的身份验证,或类似代理的模式:由 Centrifugo 向你的后端发起请求,以验证每个连接。
它能与哪些监控工具集成?它提供大量 Prometheus 指标,并附带官方 Grafana 仪表盘,另外还内置了管理网页界面,用于查看实时连接和发布消息。
Size
168.1 MB
Stars
10.9K
Age
11y
Commits · 90 Days