Centrifugo
Centrifugo is a real-time messaging server. It’s language-agnostic and can be used in conjunction with application…
- Misc
- 4.9K
Centrifugo is a real-time messaging server. It’s language-agnostic and can be used in conjunction with application…
Centrifugo is a real-time messaging server. It’s language-agnostic and can be used in conjunction with application backend written in any language – Python, Ruby, Perl, PHP, Javascript, Java, Objective-C etc.
Centrifugo runs as separate service and keeps persistent Websocket or SockJS connections from your application clients (from web browsers or other environments like iOS or Android apps). When some event happens you can broadcast it to all interested clients using Centrifugo API.
There are lots of projects for solving real-time problem. Most of them only provide PUB/SUB feature — i.e. a way to deliver messages to clients. Centrifugo have more to offer out of the box to build real-time apps. Here is a very short description of main features Centrifugo has.
Presence information. This is an information about current connections to specific channel. The most obvious example is chat room – we want to see to is online at moment.
Next — join/leave events — again in an example with chat room this is notifications when someone joins/leaves room.
Another thing is that Centrifugo allows to keep message history (cache) for channels during configurable amount of time and with configurable size. This is not very useful alone but allows to recover missed messages (during short network disconnections for example).
Another common problem is client load balancing. What if our application has 100k clients online? Of course in theory we can use only one machine to handle all connections (and even more). But this is bad because of two main reasons:
service availability. What if your Centrifugo machine breaks?
more clients mean more CPU resources and higher message latencies — why not to relax your instance adding another one?
So to scale on several machines and load balance clients between them Centrifugo can be started with Redis engine. Centrifugo nodes will be connected over Redis PUB/SUB mechanism and all temporary information such as presence and message history information will be kept in Redis instead of process memory. Centrifugo works with Redis Sentinel to prevent Redis being single point of failure.
Tell us about a new Kubernetes application
Never miss a thing! Sign up for our newsletter to stay updated.
Discover and learn about everything Kubernetes