Adds integration with Centrifuge.
Centrifugo is a self-hosted service which can handle connections over a variety of real-time transports and provides a simple publish API. Centrifugo integrates well with any application – no need to change an existing application architecture to introduce real-time features. Just let Centrifugo deal with persistent connections.
Great performance
Centrifugo is built in Go language with some smart optimizations inside. It has good performance – test stand with one million WebSocket connections and 30 million delivered messages per minute with hardware comparable to one modern server machine.
Feature-rich
Many built-in features can help to build an attractive real-time application in a limited time. Centrifugo provides different types of subscriptions, hot channel history, instant presence, RPC calls. There is also the possibility to proxy connection events to the application backend over HTTP or GRPC and more.
Built-in Redis, KeyDB, Tarantool engines, or Nats broker make it possible to scale connections over different machines. With consistent sharding of Redis, KeyDB, and Tarantool it's possible to handle millions of active connections with reasonable hardware requirements.
Used in production
Started almost 10 years back then Centrifugo (and Centrifuge library for Go it's built on top of) is a mature server successfully used in production by many companies around the world: Badoo, Ably, ManyChat, Grafana, and others.
What is real-time messaging?
Real-time messaging can help building interactive applications where events can be delivered to users almost immediately after being acknowledged by application backend by pushing data into persistent connection – thus achieving minimal delivery latency.
Chats, live comments, multiplayer games, streaming metrics can be built on top of a real-time messaging system.
Centrifugo handles persistent connections from clients over bidirectional WebSocket, SockJS, and unidirectional SSE (EventSource), HTTP-streaming, GRPC transports and provides API to publish messages to online clients in real-time.
Scalability
Another important thing is scalability. As your application grows — more and more users will establish persistent connections with your real-time endpoint. A modern server machine can handle thousands of open connections but the power of one process is limited — you will eventually run out of available CPU or memory. So at some point you may have to scale user connections over several machines. Another reason to scale connections over several machines is high availability (when one servers out of order).
There are many real-time messaging solutions on Github and paid online services. But only few of them provide scalability out of the box — most of them work only in one process. I don’t want to say that Centrifugo is the only server that scales. There are still many alternatives like Socket.IO, SocketCluster, Pushpin and tons of others. My point is that possibility to scale is one of the main things you should think about when searching for real-time solution or building it from scratch. You can’t really predict how fast your app will run out available resources on single machine — software scalability is not a premature optimization and in most cases having scalable solution out of the box will simply give you more room for improving application functionality.
Many online services are capable to scale too. But look at pricing — most of those solutions are rather expensive. In case of pusher.com you are paying 500$ in a month but only get 10k connections max and strongly limited amount of monthly messages you should care about. This is ridiculous. Of course Centrifugo is self hosted and you must spend your server’s capacity to run it. But I suppose the cost is not comparable in many cases.
Centrifugo scales well with Redis PUB/SUB, supports application-side Redis consistent sharding out of the box and integrates with Redis Sentinel for high availability. We served up to 500k connections with Centrifugo having 10 Centrifugo node pods for connections in Kubernetes and only one Redis instance which consumed only 60% of single processor core!
There is also an ongoing pull request that adds possibility to scale PUB/SUB with Nats server as broker.
Version 2.2.1 :
Add new options host address and path
Add information on admin dashboard
Add missing requirement add-on [MMO] Core Library
Version 2.2.2 :
Add cli command: mcgo-centrifugo:info
Generate jwt token for subcription
We pass the token that we generated. Also, if an empty string is passed and you do not need to generate tokens every time for guests, specify in the setting
If you are using our add-ons, then you must remove these options from the configuration. Because they are no longer relevant.
If you are using the live threads add-on ([MMO] Live Threads)
You must add a namespace. Example configuration with live threads :
You can find information about namespaces here :
centrifugal.dev
Version 2.2.3 :
Minimum version of Core Lib 2.2.4
The server must use centrifuge version 4
!!! To switch to v4, use the built-in config migration tool :
centrifugal.dev
When using the addition of live conversations or threads, it does not go to the last message, but remains in the same position. On large forums, this causes discomfort.
Added new triggers and their handling, now you can inline your code while connecting to a socket and when you connected to it.
In case of successful connection Client states will transition like this:
In case of already connected Client temporary lost a connection with a server and then successfully reconnected:
In case of already connected Client temporary lost a connection with a server, but got a terminal error upon reconnection:
In case of already connected Client came across terminal condition (for example, if during a connection token refresh application found that user has no permission to connect anymore):
Both connecting and disconnected events have numeric code and human-readable string reason in their context, so you can look at them and find the exact reason why the Client went to the connecting state or to the disconnected state.
This diagram demonstrates possible Client state transitions :
The following events will be available soon:
subscribed - Called when subscribed to a server-side channel upon Client moving to connected state or during connection lifetime if server sends Subscribe push message.
subscribing - Called when existing connection lost (Client reconnects) or Client explicitly disconnected. Client continue keeping server-side subscription registry with stream position information where applicable.
unsubscribed - Called when server sent unsubscribe push or server-side subscription
publication
This diagram demonstrates possible Subscription state transitions :
Version 2.3.0 Beta 1 :
- Support XF 2.3.0
- Min require XF 2.3.0 Beta 3
- Update js code (thx @NikitOS)
Version 2.3.0 :
- Min require 2.3.0
- Using new pattern XF
- Refactoring
Version 2.3.1 : Fixed a bug in 2.3 where messages were not added to a thread when there were no pages (pagination).
Version 2.3.2 :
Update centrifugo js
Updated js completely to work with centrifuge. Now this core as originally planned, no elements are processed. Only connections, event handling and channel subscriptions
js with a centrifuge and a connection to it now goes on all pages, this is done specifically to allow other add-ons to interact with it and use elements on other pages
To switch to version 6, use the migration service:
centrifugal.dev.
Example of a new config:
Version 2.3.3 :
- Now the connection token is generated on all pages, if you want to override you can set your parameters in the constructor for the token, host and path.
Added a check for subscribing to an existing channel.
Version 2.3.4 : Add new option Channel Instance ID
Centrifugo is a self-hosted service which can handle connections over a variety of real-time transports and provides a simple publish API. Centrifugo integrates well with any application – no need to change an existing application architecture to introduce real-time features. Just let Centrifugo deal with persistent connections.
Great performance
Centrifugo is built in Go language with some smart optimizations inside. It has good performance – test stand with one million WebSocket connections and 30 million delivered messages per minute with hardware comparable to one modern server machine.
Feature-rich
Many built-in features can help to build an attractive real-time application in a limited time. Centrifugo provides different types of subscriptions, hot channel history, instant presence, RPC calls. There is also the possibility to proxy connection events to the application backend over HTTP or GRPC and more.
Built-in Redis, KeyDB, Tarantool engines, or Nats broker make it possible to scale connections over different machines. With consistent sharding of Redis, KeyDB, and Tarantool it's possible to handle millions of active connections with reasonable hardware requirements.
Used in production
Started almost 10 years back then Centrifugo (and Centrifuge library for Go it's built on top of) is a mature server successfully used in production by many companies around the world: Badoo, Ably, ManyChat, Grafana, and others.
What is real-time messaging?
Real-time messaging can help building interactive applications where events can be delivered to users almost immediately after being acknowledged by application backend by pushing data into persistent connection – thus achieving minimal delivery latency.
Chats, live comments, multiplayer games, streaming metrics can be built on top of a real-time messaging system.
Centrifugo handles persistent connections from clients over bidirectional WebSocket, SockJS, and unidirectional SSE (EventSource), HTTP-streaming, GRPC transports and provides API to publish messages to online clients in real-time.
Scalability
Another important thing is scalability. As your application grows — more and more users will establish persistent connections with your real-time endpoint. A modern server machine can handle thousands of open connections but the power of one process is limited — you will eventually run out of available CPU or memory. So at some point you may have to scale user connections over several machines. Another reason to scale connections over several machines is high availability (when one servers out of order).
There are many real-time messaging solutions on Github and paid online services. But only few of them provide scalability out of the box — most of them work only in one process. I don’t want to say that Centrifugo is the only server that scales. There are still many alternatives like Socket.IO, SocketCluster, Pushpin and tons of others. My point is that possibility to scale is one of the main things you should think about when searching for real-time solution or building it from scratch. You can’t really predict how fast your app will run out available resources on single machine — software scalability is not a premature optimization and in most cases having scalable solution out of the box will simply give you more room for improving application functionality.
Many online services are capable to scale too. But look at pricing — most of those solutions are rather expensive. In case of pusher.com you are paying 500$ in a month but only get 10k connections max and strongly limited amount of monthly messages you should care about. This is ridiculous. Of course Centrifugo is self hosted and you must spend your server’s capacity to run it. But I suppose the cost is not comparable in many cases.
Centrifugo scales well with Redis PUB/SUB, supports application-side Redis consistent sharding out of the box and integrates with Redis Sentinel for high availability. We served up to 500k connections with Centrifugo having 10 Centrifugo node pods for connections in Kubernetes and only one Redis instance which consumed only 60% of single processor core!
There is also an ongoing pull request that adds possibility to scale PUB/SUB with Nats server as broker.
Version 2.2.1 :
Add new options host address and path
Add information on admin dashboard
Add missing requirement add-on [MMO] Core Library
Version 2.2.2 :
Add cli command: mcgo-centrifugo:info
Generate jwt token for subcription
We pass the token that we generated. Also, if an empty string is passed and you do not need to generate tokens every time for guests, specify in the setting
JSON:
You must log in to view
(2 lines)
If you are using the live threads add-on ([MMO] Live Threads)
You must add a namespace. Example configuration with live threads :
JSON:
You must log in to view
(14 lines)
centrifugal.dev
Version 2.2.3 :
Minimum version of Core Lib 2.2.4
The server must use centrifuge version 4
!!! To switch to v4, use the built-in config migration tool :
centrifugal.dev
When using the addition of live conversations or threads, it does not go to the last message, but remains in the same position. On large forums, this causes discomfort.
Added new triggers and their handling, now you can inline your code while connecting to a socket and when you connected to it.
In case of successful connection Client states will transition like this:
disconnected (initial) -> connecting (on('connecting') called)
-> connected (on('connected') called)
.In case of already connected Client temporary lost a connection with a server and then successfully reconnected:
connected -> connecting (on('connecting') called)
-> connected (on('connected') called)
.In case of already connected Client temporary lost a connection with a server, but got a terminal error upon reconnection:
connected
-> connecting (on('connecting') called)
-> disconnected (on('disconnected') called)
.In case of already connected Client came across terminal condition (for example, if during a connection token refresh application found that user has no permission to connect anymore):
connected
-> disconnected (on('disconnected') called)
.Both connecting and disconnected events have numeric code and human-readable string reason in their context, so you can look at them and find the exact reason why the Client went to the connecting state or to the disconnected state.
This diagram demonstrates possible Client state transitions :
The following events will be available soon:
subscribed - Called when subscribed to a server-side channel upon Client moving to connected state or during connection lifetime if server sends Subscribe push message.
subscribing - Called when existing connection lost (Client reconnects) or Client explicitly disconnected. Client continue keeping server-side subscription registry with stream position information where applicable.
unsubscribed - Called when server sent unsubscribe push or server-side subscription
publication
This diagram demonstrates possible Subscription state transitions :
Version 2.3.0 Beta 1 :
- Support XF 2.3.0
- Min require XF 2.3.0 Beta 3
- Update js code (thx @NikitOS)
Version 2.3.0 :
- Min require 2.3.0
- Using new pattern XF
- Refactoring
Version 2.3.1 : Fixed a bug in 2.3 where messages were not added to a thread when there were no pages (pagination).
Version 2.3.2 :
Update centrifugo js
Updated js completely to work with centrifuge. Now this core as originally planned, no elements are processed. Only connections, event handling and channel subscriptions
js with a centrifuge and a connection to it now goes on all pages, this is done specifically to allow other add-ons to interact with it and use elements on other pages
To switch to version 6, use the migration service:
centrifugal.dev.
Example of a new config:
Code:
You must log in to view
(30 lines)
Version 2.3.3 :
- Now the connection token is generated on all pages, if you want to override you can set your parameters in the constructor for the token, host and path.
Added a check for subscribing to an existing channel.
Version 2.3.4 : Add new option Channel Instance ID
Attachments
-
MMO-Centrifuge-2.2.0.zip418.5 KB · Views: 0
-
MMO-Centrifuge-2.2.2.zip424.4 KB · Views: 0
-
MMO-Centrifuge-2.2.3.zip232.4 KB · Views: 0
-
MMO-Centrifuge-2.3.0 Beta 1.zip233.4 KB · Views: 0
-
MMO-Centrifuge-2.3.0.zip233.9 KB · Views: 0
-
MMO-Centrifuge-2.3.1.zip233.9 KB · Views: 0
-
MMO-Centrifuge-2.3.3.zip278.6 KB · Views: 0
-
MMO-Centrifuge-2.3.4.zip280.1 KB · Views: 0