Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsApr 13, 2026·3 min de lectura

Centrifugo — Scalable Real-Time Messaging Server

Centrifugo is a scalable real-time messaging server that adds live updates to any application. It handles WebSocket connections, scales horizontally with Redis or NATS, and provides a language-agnostic API — a self-hosted alternative to Pusher, Ably, and Socket.IO.

Listo para agents

Instalación con revisión previa

Este activo requiere revisión. El prompt copiado pide dry-run, muestra escrituras y continúa solo tras confirmación.

Needs Confirmation · 64/100Política: confirmar
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
step-1.md
Comando con revisión previa
npx -y tokrepo@latest install 8dcc33b8-3734-11f1-9bc6-00163e2b0d79 --target codex

Primero dry-run, confirma las escrituras y luego ejecuta este comando.

TL;DR
Centrifugo adds scalable real-time messaging to any application via WebSocket, SSE, and HTTP streaming with Redis or Nats backends.
§01

What it is

Centrifugo is a scalable real-time messaging server that adds live update capabilities to any application regardless of its tech stack. It handles WebSocket connections, Server-Sent Events (SSE), HTTP streaming, and GRPC transports. The server is language-agnostic -- your backend publishes messages via HTTP or GRPC API, and Centrifugo delivers them to connected clients in real time. It supports Redis, Nats, and Tarantool as scalable backends for multi-node deployments.

Development teams that need to add real-time features (live notifications, chat, dashboards, collaborative editing) to existing applications without rewriting their backend benefit most.

§02

How it saves time or tokens

Centrifugo decouples real-time message delivery from your application logic. Instead of implementing WebSocket handling, connection management, heartbeats, reconnection logic, and horizontal scaling yourself, you deploy Centrifugo as a sidecar service. Your backend only needs to make HTTP calls to publish messages. This reduces the engineering effort from weeks of WebSocket infrastructure work to hours of integration.

§03

How to use

  1. Install and run Centrifugo:
# Docker
docker run -p 8000:8000 centrifugo/centrifugo:latest centrifugo --admin

# Or download binary
curl -sSL https://centrifugal.dev/install.sh | sh
centrifugo --config config.json
  1. Connect from a client:
import { Centrifuge } from 'centrifuge';

const client = new Centrifuge('ws://localhost:8000/connection/websocket');
const sub = client.newSubscription('notifications');
sub.on('publication', (ctx) => {
  console.log('New message:', ctx.data);
});
sub.subscribe();
client.connect();
  1. Publish from your backend:
curl -X POST http://localhost:8000/api/publish \
  -H 'Authorization: apikey YOUR_API_KEY' \
  -d '{"channel": "notifications", "data": {"text": "Hello"}}'
§04

Example

# Python backend publishing to Centrifugo
import requests

def notify_user(user_id, message):
    requests.post('http://centrifugo:8000/api/publish', json={
        'channel': f'user:{user_id}',
        'data': {'type': 'notification', 'text': message}
    }, headers={'Authorization': 'apikey YOUR_API_KEY'})
§05

Related on TokRepo

§06

Common pitfalls

  • Centrifugo requires a backend engine (Redis, Nats) for horizontal scaling. A single-node deployment works for development but does not scale in production without a broker.
  • Client tokens must be generated by your backend with a shared secret. Exposing the API key in client-side code creates a security vulnerability.
  • Channel naming conventions matter for authorization. Use namespaces to separate public channels from private user channels.

Preguntas frecuentes

What transports does Centrifugo support?+

Centrifugo supports WebSocket (bidirectional), Server-Sent Events (SSE, server-to-client), HTTP streaming, and GRPC. Clients automatically negotiate the best available transport. WebSocket is preferred for bidirectional communication.

Can Centrifugo scale horizontally?+

Yes. Centrifugo supports Redis, Nats, and Tarantool as broker backends for multi-node deployments. Messages published to any node are distributed to subscribers connected to any other node through the broker.

Does Centrifugo support authentication?+

Yes. Centrifugo uses JWT tokens for client authentication. Your backend generates a token with user identity and channel permissions. The server validates the token on connection and enforces channel-level authorization.

What languages have Centrifugo client SDKs?+

Official client SDKs exist for JavaScript (browser and Node.js), Go, Python, Dart (Flutter), Swift (iOS), and Java/Kotlin (Android). The JavaScript SDK is the most commonly used for web applications.

Is Centrifugo open source?+

Yes. Centrifugo is open source under the MIT license. The server, client SDKs, and documentation are all freely available. A commercial Centrifugo PRO version adds features like push notifications and analytics.

Referencias (3)

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados