Skip to main content

Notable Centrifugo v5 milestones in 2024

ยท 9 min read
Centrifugal team
Centrifugal team
๐Ÿ’ปโœจ๐Ÿ”ฎโœจ๐Ÿ’ป

While we concentrate our main efforts on Centrifugo v6 development, let's recap the most notable features and improvements introduced during Centrifugo v5 lifecycle.

We are excited about how many things done in 2024 we can be proud of. Also, we are grateful to our community for the feedback, support and love towards the project we see.

Let's start remembering what had happened with the project over the year.

Grand Tutorial โ€“ the most advanced WebSocket chat app tutorialโ€‹

We launched the Grand Tutorial, an official step-by-step guide how to build a complex real-time application with Centrifugo. This comprehensive tutorial walks developers through the entire process, implementing client side, server side and Centrifugo integration. Moreover, it gives answers to robust message delivery and provides performance estimation you can expect to achieve with Centrifugo.

Built-in asynchronous consumersโ€‹

While working on the Grand Chat Tutorial, we realized that Centrifugo could natively consume external queues to simplify integration with the existing backends. Thus, at some point of v5 life cycle built-in asynchronous consumers were introduced. At this point we have two types of them:

  • PostgreSQL Outbox Table. Enables seamless integration with transactional outbox pattern for reliable messaging. Save your model and emit event to Centrifugo in one transaction.
  • Kafka Topics. Native Kafka topic consumption makes Centrifugo even more versatile for real-time event streaming.

You can find examples how both can be used in Broadcast using transactional outbox and CDC chapter of the tutorial.

In v6 we continue improving asynchronous consumers and adding a new mode for Kafka consumer โ€“ more details very soon! During v6 life cycle we can add more built-in integrations with popular queue systems.

Idempotency key for publish APIโ€‹

The addition of idempotency_key in publish and broadcast server API methods provides an effective way to prevent duplicate messages and ensure consistency in a distributed system as it gives a way to safely make publication retries upon network failures.

gRPC Proxy Subscription Streamsโ€‹

Centrifugo v5.1.0 introduced an experimental support for gRPC proxy subscription streams. This feature allows developers to send individual stream of events to the client using gRPC-streaming based proxies (bidirectional or unidirectional), providing a way to integrate with third-party existing streams using GRPC streaming between Centrifugo and backend.

Technically, this is quite an interesting concept โ€“ Centrifugo can multiplex different streams within a single WebSocket connection (or any other supported transport like SSE or HTTP-streaming), and the communication between Centrifugo and the backend is multiplexed within a single HTTP/2 connection (used by GRPC internally).

This feature makes it possible to integrate with external streams in munutes. If you've ever heard about WebSocketd โ€“ then the idea is very similar, but over the network! With multiplexing, authentication, authorization, scalabilty Centrifugo features coming with the concept out-of-the-box.

See also Stream logs from Loki to browser with Centrifugo Websocket-to-GRPC subscriptions relevant blog post.

Delta Compression in Channelsโ€‹

Delta compression based on Fossil algorithm was introduced to minimize data transfer overhead in channels, optimizing performance and bandwidth usage during real-time message delivery. The feature is quite unique for self-hosted real-time messaging systems. And we'd like to note that now we not only support delta compression in JavaScript SDK, but recently the community contributed support for it to our Java and Python SDKs. And there is an ongoing PR to Swift SDK.

delta frames

See example where delta compression can be very beneficial in Experimenting with real-time data compression by simulating a football match events blog post.

Cache recovery mode for channelsโ€‹

The new cache recovery mode in Centrifugo transforms channels into real-time caches by delivering only the most recent message upon resubscription. This feature has proven highly effective for AzuraCast's "Now Playing" functionality, ensuring effective updates for users. With Centrifugoโ€™s cache recovery mode, the system now operates more efficiently, significantly reducing the load on the backend.

Expanded observabilityโ€‹

Several new metrics were added to provide deeper insights into Centrifugo operations. A couple of examples:

  • centrifugo_node_pub_sub_lag_seconds: tracks lag in pub/sub processing โ€“ may be very important for server monitoring.
  • centrifugo_client_ping_pong_duration_seconds: measures client latency distribution on top of existing ping-pong mechanism with transport type resolution.

Metrics would be one of the main focuses of Centrifugo v6, so we will continue working hard on better observability of Centrifugo.

Nats integration improvementsโ€‹

  • Raw mode. Offers a way to consume existing Nats topics with 1-to-1 matching to Centrifugo channels
  • It's now possible to have wildcard subscriptions with Nats โ€“ i.e. a way to consume from many channels having only one subscription.

The useful addition in Centrifugo PRO was a possibility to use per-namespace brokers and presence managers. So it's possible to use wildcard subscriptions with Nats in one channel namespace, and benefit from Redis broker features (presence, history cache and automatic recovery) in other channel namespaces.

Redis integration improvementsโ€‹

  • Redis 7.4 added possibility to set per field TTL in HASH data structure. We utilized this for Centrifugo presence to handle online presence more efficiently and reducing the overhead of presence requests.
  • Global Redis Presence User Mapping. We've provided an option to drastically improve presence_stats performance for channels with a large number of active subscribers, making Redis-backed deployments more efficient.
  • Centrifugo works gracefully with Redis eviction algorithms now. It degrades in a way that clients lose their positions in channel streams, but they can recover in idiomatic way.

Better SDKsโ€‹

Several improvements were made in client SDKs. Among others, we'd like to highlight the following:

  • some important connection stability and correctness improvements in Javascript SDK, for example this one where we fixed WebSocket is closed before the connection is established error preventing reconnect after long offline period, or this one where we worked on the correctness of quick subscribe/unsubscribe scenarios.
  • at some point we brought back to life our Python realtime SDK. For many years we did not have enough resources to do this, but now we are happy to see it alive again.
  • delta compression support in Javascript SDK. And later the support for it was added in Java and Python SDKs, and that was contributed by Centrifugal community members which is simply great.
  • a method to reset reconnecting state in Swift SDK, which can be expanded to other SDKs in the future. Previously, we only had similar functionality in Javascript SDK where browser online/offline notifications are available.
  • we now have a high-quality alternative to our official Dart/Flutter SDK โ€“ see https://github.com/PlugFox/spinify made by PlugFox. An alternative may provide more idiomatic API for Dart developers, more performance and customization.

Centrifugo PRO milestonesโ€‹

In v5 release post we introduced Centrifugal Labs โ€“ a company around Centrifugo PRO product, the enhanced version of Centrifugo. It was operational since then. During the year we found new PRO customers, and generally passed very important milestones as a company.

The most important for this post is that we continued to improve Centrifugo PRO with new features. Let's recap!

Compression improvementsโ€‹

The first thing to mention regarding Centrifugo PRO is compression performance optimizations. We introduced the cache for prepared WebSocket messages to reduce CPU usage and improve compression ratio. This feature was very helpful for our customers who have a lot of data to send over WebSocket connections. Also, delta compression for channels with at most once delivery guarantees is available for Centrifugo PRO users.

Better observabilityโ€‹

We believe that PRO version should provide an enhanced observability as when the business grows it's crucial to have a deep insight into the system. One notable feature is namespace segmentation for in/out message size metrics. This allows identifying namespaces which consume a lot of bandwidth. In Centrifugo v6 we will make a step forward here, stay tuned!

New features for push notificationsโ€‹

One of the most attractive features of Centrifugo PRO is push notifications support. During the year several notable improvements were made regarding it. Let's recap.

Timezone-aware push notifications โ€“ Centrifugo PRO can now send push notifications based on device timezone. Or notification templating - allows using variables and substitute them to values based on particular device metadata. Also, notification localizations - for providing translations of push content based on particular device locale. Next, per user device rate limiting - lets app developers be more careful about the number and rate of push notifications on per user device basis.

And finally, better scalability of push notification device/topic storage by using reads from PostgreSQL replicas.

Channel state events previewโ€‹

We published a Channel state events feature preview โ€“ to be notified about channel occupied and channel vacated events on the app backend. Note that we do not recommend this feature for production usage yet. While it may seem simple - the implementation is quite complex under the hood, because we try to solve important issues like event ordering, avoiding event race conditions, making sure we survive Centrifugo node restarts, scalability with Redis Cluster. This all requires a careful approach, so we want to step-by-step improve the feature based on the customer feedback. In Centrifugo v6, we make a little step forward with channel state events, will share more details very soon.

SSO for admin UIโ€‹

We added SSO for admin UI using OpenID connect (OIDC)protocol, this is a very natural feature to have for corporate users who want to use their existing identity provider to authenticate in Centrifugo admin UI instead of custom password management.

Centrifugo v6 is comingโ€‹

There were more improvements and features introduced during Centrifugo v5 lifecycle, here we tried to highlight the most notable ones. This year was quite productive for the project, and we hope your work was more productive due to the help of Centrifugo.

We are looking forward to the upcoming year and the release of Centrifugo v6 very soon. Stay tuned for the upcoming announcement where we will introduce the new features and improvements of the new major release.

Merry Christmas and Happy New Year everyone! ๐ŸŽ„