PageSourceSearch

https://centrifugal.dev/assets/js/9c1ee1d6.fda1f041.js

js centrifugal.dev collected 2026-09-25 19:01:42 UTC 31,012 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkcentrifugal_dev=self.webpackChunkcentrifugal_dev||[]).push([[1553],{28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>a});var i=t(96540);const o={},r=i.createContext(o);function s(e){const n=i.useContext(r);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:s(e.components),i.createElement(r.Provider,{value:n},e.children)}},80352:e=>{e.exports=JSON.parse('{"permalink":"/blog/2021/08/31/hello-centrifugo-v3","editUrl":"https://github.com/centrifugal/centrifugal.dev/edit/main/blog/2021-08-31-hello-centrifugo-v3.md","source":"@site/blog/2021-08-31-hello-centrifugo-v3.md","title":"Centrifugo v3 released","description":"Centrifugo v3 released with lots of exciting improvements","date":"2021-08-31T00:00:00.000Z","tags":[{"inline":true,"label":"centrifugo","permalink":"/blog/tags/centrifugo"},{"inline":true,"label":"release","permalink":"/blog/tags/release"}],"readingTime":15.55,"hasTruncateMarker":true,"authors":[{"name":"Centrifugal team","title":"Let the Centrifugal force be with you","imageURL":"/img/logo_animated.svg","key":null,"page":null}],"frontMatter":{"title":"Centrifugo v3 released","tags":["centrifugo","release"],"description":"Centrifugo v3 released with lots of exciting improvements","author":"Centrifugal team","authorTitle":"Let the Centrifugal force be with you","authorImageURL":"/img/logo_animated.svg","image":"/img/v3_blog.jpg","hide_table_of_contents":false},"unlisted":false,"prevItem":{"title":"Centrifugo integration with NodeJS tutorial","permalink":"/blog/2021/10/18/integrating-with-nodejs"},"nextItem":{"title":"Centrifuge \u2013 real-time messaging with Go","permalink":"/blog/2021/01/15/centrifuge-intro"}}')},86601:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>a,default:()=>d,frontMatter:()=>s,metadata:()=>i,toc:()=>c});var i=t(80352),o=t(74848),r=t(28453);const s={title:"Centrifugo v3 released",tags:["centrifugo","release"],description:"Centrifugo v3 released with lots of exciting improvements",author:"Centrifugal team",authorTitle:"Let the Centrifugal force be with you",authorImageURL:"/img/logo_animated.svg",image:"/img/v3_blog.jpg",hide_table_of_contents:!1},a=void 0,l={authorsImageUrls:[void 0]},c=[{value:"Centrifugo v2 flashbacks",id:"centrifugo-v2-flashbacks",level:3},{value:"Backwards compatibility",id:"backwards-compatibility",level:3},{value:"License change",id:"license-change",level:3},{value:"Unidirectional real-time transports",id:"unidirectional-real-time-transports",level:3},{value:"History iteration API",id:"history-iteration-api",level:3},{value:"Redis Streams by default",id:"redis-streams-by-default",level:3},{value:"Tarantool engine",id:"tarantool-engine",level:3},{value:"GRPC proxy",id:"grpc-proxy",level:3},{value:"Server API improvements",id:"server-api-improvements",level:3},{value:"Better clustering",id:"better-clustering",level:3},{value:"Client improvements",id:"client-improvements",level:3},{value:"New documentation site",id:"new-documentation-site",level:3},{value:"Performance improvements",id:"performance-improvements",level:3},{value:"Centrifugo PRO",id:"centrifugo-pro",level:3},{value:"Conclusion",id:"conclusion",level:3}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.p,{children:"After almost three years of Centrifugo v2 life cycle we are happy to announce the next major release of Centrifugo. During the last several months deep in our Centrifugal laboratory we had been synthesizing an improved version of the server."}),"\n",(0,o.jsx)(n.p,{children:"New Centrifugo v3 is targeting to improve Centrifugo adoption for basic real-time application cases, improves server performance and extends existing features with new functionality. It comes with unidirectional real-time transports, protocol speedups, super-fast engine implementation based on Tarantool, new documentation site, GRPC proxy, API extensions and PRO version which provides unique possibilities for business adopters."}),"\n",(0,o.jsx)(n.h3,{id:"centrifugo-v2-flashbacks",children:"Centrifugo v2 flashbacks"}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo v2 life cycle has come to an end. Before discussing v3 let's look back at what has been done during the last three years."}),"\n",(0,o.jsxs)(n.p,{children:["Centrifugo v2 was a pretty huge refactoring of v1. Since the v2 release, Centrifugo is built on top of  new ",(0,o.jsx)(n.a,{href:"https://github.com/centrifugal/centrifuge",children:"Centrifuge library"})," for Go language. Centrifuge library evolved significantly since its initial release and now powers Grafana v8 real-time streaming among other things."]}),"\n",(0,o.jsxs)(n.p,{children:["Here is an awesome demo made by my colleague ",(0,o.jsx)("a",{href:"https://github.com/alexanderzobnin",children:"Alexander Zobnin"})," that demonstrates real-time telemetry of Assetto Corsa sports car streamed in real-time to Grafana dashboard:"]}),"\n",(0,o.jsx)("div",{class:"vimeo-full-width",children:(0,o.jsx)("iframe",{src:"https://player.vimeo.com/video/570333329?title=0&byline=0&portrait=0",frameBorder:"0",allow:"autoplay; fullscreen",allowFullScreen:!0})}),"\n",(0,o.jsx)("p",{}
1),"\n",(0,o.jsxs)(n.p,{children:["Centrifugo integrated with Redis Streams, got Redis Cluster support, can now work with Nats server as a PUB/SUB broker. Notable additions of Centrifugo v2 were ",(0,o.jsx)(n.a,{href:"/docs/server/server_subs",children:"server-side subscriptions"})," with some interesting features on top \u2013 like maintaining a single global connection from one user and automatic personal channel subscription upon user connect."]}),"\n",(0,o.jsxs)(n.p,{children:["A very good addition which increased Centrifugo adoption a lot was introduction of ",(0,o.jsx)(n.a,{href:"/docs/server/proxy",children:"proxy to backend"}),". This made Centrifugo fit many setups where JWT authentication and existing subscription permission model did not suit well before."]}),"\n",(0,o.jsx)(n.p,{children:"Client ecosystem improved significantly. The fact that client protocol migrated to a strict Protobuf schema allowed to introduce binary protocol format (in addition to JSON) and simplify building client connectors. We now have much better and complete client libraries (compared to v1 situation)."}),"\n",(0,o.jsxs)(n.p,{children:["We also have an ",(0,o.jsx)(n.a,{href:"https://github.com/centrifugal/helm-charts",children:"official Helm chart"}),", ",(0,o.jsx)(n.a,{href:"https://grafana.com/grafana/dashboards/13039",children:"Grafana dashboard"})," for Prometheus datasource, and so on."]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.img,{src:"https://grafana.com/api/dashboards/13039/images/8950/image",alt:""})}),"\n",(0,o.jsxs)(n.p,{children:["Centrifugo is becoming more noticeable in a wider real-time technology community. For example, it was included in a ",(0,o.jsx)(n.a,{href:"https://ably.com/periodic-table-of-realtime",children:"periodic table of real-time"})," created by Ably.com (one of the most powerful real-time messaging cloud services at the moment):"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.img,{src:"https://ik.imagekit.io/ably/ghost/prod/2021/08/periodic-table-screenshots-combined-without-banner-no-legend.jpg?tr=w-1520",alt:""})}),"\n",(0,o.jsx)(n.p,{children:"Of course, there are many aspects where Centrifugo can be improved. And v3 addresses some of them. Below we will look at the most notable features and changes of the new major Centrifugo version."}),"\n",(0,o.jsx)(n.h3,{id:"backwards-compatibility",children:"Backwards compatibility"}),"\n",(0,o.jsx)(n.p,{children:"Let's start with the most important thing \u2013 backwards compatibility concerns."}),"\n",(0,o.jsx)(n.p,{children:"In Centrifugo v3 client protocol mostly stayed the same. We expect that most applications will be able to update without any change on a client-side. This was an important concern for v3 given how painful the update cycle can be on mobile devices and lessons learned from v1 to v2 migration. There is one breaking change though which can affect users who use history API manually from a client-side (we provide a temporary workaround to give apps a chance to migrate smoothly)."}),"\n",(0,o.jsxs)(n.p,{children:["On a server-side, much more changes happened, especially in the configuration: some options were renamed, some were removed. We provide a ",(0,o.jsx)(n.a,{href:"/docs/3/getting-started/migration_v3#v2-to-v3-config-converter",children:"v2 to v3 configuration converter"})," which can help dealing with changes. In most cases, all you should do is adapt Centrifugo configuration to match v3 changes and redeploy Centrifugo using v3 build instead of v2. All features are still there (or a replacement exists, like for ",(0,o.jsx)(n.code,{children:"channels"})," API)."]}),"\n",(0,o.jsxs)(n.p,{children:["For more details, refer to the ",(0,o.jsx)(n.a,{href:"/docs/3/getting-started/migration_v3",children:"v3 migration guide"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"license-change",children:"License change"}),"\n",(0,o.jsx)(n.p,{children:"As some of you know we considered changing Centrifugo license to AGPL v3 for a new release. After thinking a lot about this we decided to not step into this area."}),"\n",(0,o.jsx)(n.p,{children:"But the license has been changed: the license of OSS Centrifugo is now Apache 2.0 instead of MIT. Apache 2.0 is also a permissive OSS license, it's just a bit more concrete in some aspects."}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.img,{src:"https://user-images.githubusercontent.com/2097922/91162089-8570e100-e6c3-11ea-8c41-cd8fcfe049d0.png",alt:""})}),"\n",(0,o.jsx)(n.h3,{id:"unidirectional-real-time-transports",children:"Unidirectional real-time transports"}),"\n",(0,o.jsx)(n.p,{children:"Server-side subscriptions introduced in Centrifugo v2 and recent improvements in the underlying Centrifuge library opened a road for a unidirectional approach."}),"\n",(0,o.jsx)(n.p,{children:"This means that Centrifugo v3 provides a set of unidirectional real-time transports where messages flow only in one direction \u2013 from a server to a client. Why is this change important?"}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo originally concentrated on using bidirectional transports for client-server communication. Like WebSocket and SockJS. Bidirectional transports allow implementing some great protocol features since a client can communicate with a server in various ways after establishing a persistent connection. While this is a great opportunity this also leads to an increased complexity."}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo users had to use special client connector libraries which abstracted underlying work into a simple public API. But internally connectors do many things: matching requests to responses, handling timeouts, handling an ordering, queuing operations, error handling. So the client connector is a pretty complex piece of software."}),"\n",(0,o.jsx)(n.p,{children:"But what if a user just needs to receive real-time updates from a stable set of channels known in connection time? Can we simplify everything and avoid using custom softw
1are on a client-side?"}),"\n",(0,o.jsxs)(n.p,{children:["With unidirectional transports, the answer is yes. Clients can now connect to Centrifugo using a bunch of unidirectional transports. And the greatest thing is that in this case, developers should not depend on Centrifugo client connectors at all \u2013 just use native browser APIs or GRPC-generated code. It's finally possible to consume events from Centrifugo using CURL (see ",(0,o.jsx)(n.a,{href:"/docs/transports/uni_http_stream#connecting-using-curl",children:"an example"}),")."]}),"\n",(0,o.jsx)(n.p,{children:"Using unidirectional transports you can still benefit from Centrifugo built-in scalability with various engines, utilize built-in authentication over JWT or the connect proxy feature."}),"\n",(0,o.jsx)(n.p,{children:"With subscribe server API (see below) it's even possible to subscribe unidirectional client to server-side channels dynamically. With refresh server API or the refresh proxy feature it's possible to manage a connection expiration."}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo supports the following unidirectional transports:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"/docs/transports/uni_sse",children:"EventSource (SSE)"})}),"\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"/docs/transports/uni_http_stream",children:"HTTP streaming"})}),"\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"/docs/transports/uni_websocket",children:"Unidirectional WebSocket"})}),"\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"/docs/transports/uni_grpc",children:"Unidirectional GRPC stream"})}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"We expect that introducing unidirectional transports will significantly increase Centrifugo adoption."}),"\n",(0,o.jsx)(n.h3,{id:"history-iteration-api",children:"History iteration API"}),"\n",(0,o.jsx)("img",{src:"/img/centrifuge.svg",align:"right",width:"25%"}),"\n",(0,o.jsx)(n.p,{children:"There was a rather important limitation of Centrifugo history API \u2013 it was not very suitable for keeping large streams because a call to a history could only return the entire channel history."}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo v3 introduces an API to iterate over a stream. It's possible to do from the current stream beginning or end, in both directions \u2013 forward and backward, with configured limit. Also with certain starting stream position if it's known."}),"\n",(0,o.jsx)(n.p,{children:"This, among other things, can help to implement manual missed message recovery on a client-side to reduce the load on the application backend."}),"\n",(0,o.jsxs)(n.p,{children:["Here is an example program in Go which endlessly iterates over stream both ends (using ",(0,o.jsx)(n.a,{href:"https://github.com/centrifugal/gocent",children:"gocent"})," API library), upon reaching the end of stream the iteration goes in reversed direction (not really useful in real world but fun):"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-go",children:'// Iterate by 10.\nlimit := 10\n// Paginate in reversed order first, then invert it.\nreverse := true\n// Start with nil StreamPosition, then fill it with value while paginating.\nvar sp *gocent.StreamPosition\n\nfor {\n\thistoryResult, err = c.History(\n        ctx,\n        channel,\n\t\tgocent.WithLimit(limit),\n\t\tgocent.WithReverse(reverse),\n        gocent.WithSince(sp),\n\t)\n\tif err != nil {\n\t\tlog.Fatalf("Error calling history: %v", err)\n\t}\n\tfor _, pub := range historyResult.Publications {\n\t\tlog.Println(pub.Offset, "=>", string(pub.Data))\n\t\tsp = &gocent.StreamPosition{\n\t\t\tOffset: pub.Offset,\n\t\t\tEpoch:  historyResult.Epoch,\n\t\t}\n\t}\n\tif len(historyResult.Publications) < limit {\n\t\t// Got all pubs, invert pagination direction.\n\t\treverse = !reverse\n\t\tlog.Println("end of stream reached, change iteration direction")\n\t}\n}\n'})}),"\n",(0,o.jsx)(n.admonition,{type:"caution",children:(0,o.jsx)(n.p,{children:"This new API does not remove the need in having the main application database \u2013 that's still mandatory for idiomatic Centrifugo usage."})}
1),"\n",(0,o.jsx)(n.h3,{id:"redis-streams-by-default",children:"Redis Streams by default"}),"\n",(0,o.jsx)(n.p,{children:"In Centrifugo v3 Redis engine uses Redis Stream data structure by default for keeping channel history. Before v3 Redis Streams were supported by not enabled by default so almost nobody used them. This change is important in terms of introducing history iteration API described above \u2013 since Redis Streams allow doing iteration effectively."}),"\n",(0,o.jsx)(n.h3,{id:"tarantool-engine",children:"Tarantool engine"}),"\n",(0,o.jsx)(n.p,{children:"As you may know, Centrifugo has several built-in engines that allow scaling Centrifugo nodes (using PUB/SUB) and keep shared history and presence state. Before v3 Centrifugo had in-memory and Redis (or KeyDB) engines available."}),"\n",(0,o.jsx)(n.p,{children:"Introducing a new engine to Centrifugo is pretty hard since the engine should provide a very robust PUB/SUB performance, fast history and presence operations, possibility to publish a message to PUB/SUB and save to history atomically. It also should allow dealing with ephemeral frequently changing subscriptions. It's typical for Centrifugo use case to have millions of users each subscribed to a  unique channel and constantly connecting/disconnecting (thus subscribing/unsubscribing)."}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.img,{src:"https://www.tadviser.ru/images/thumb/1/1a/Tarantool_%D0%A1%D0%A3%D0%91%D0%94_logo_2020.png/840px-Tarantool_%D0%A1%D0%A3%D0%91%D0%94_logo_2020.png",alt:""})}),"\n",(0,o.jsxs)(n.p,{children:["In v3 we added ",(0,o.jsx)(n.strong,{children:"experimental"})," support for the ",(0,o.jsx)(n.a,{href:"https://www.tarantool.io/en/",children:"Tarantool"})," engine. It fits nicely all the requirements above and provides a huge performance speedup for history and presence operations compared to Redis. According to our benchmarks, the speedup can be up to 4-10x depending on operation. The PUB/SUB performance of Tarantool is comparable with Redis (10-20% worse according to our internal benchmarks to be exact, but that's pretty much the same)."]}),"\n",(0,o.jsx)(n.p,{children:"For example, let's look at Centrifugo benchmark where we recover zero messages (i.e. emulate a situations when many connections disconnected for a very short time interval due to load balancer reload)."}),"\n",(0,o.jsx)(n.p,{children:"For Redis engine:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:'title="Redis engine, single Redis instance"',children:"BenchmarkRedisRecover       26883 ns/op\t    1204 B/op\t   28 allocs/op\n"})}),"\n",(0,o.jsx)(n.p,{children:"Compare it with the same operation measured with Tarantool engine:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:'title="Tarantool engine, single Tarantool instance"',children:"BenchmarkTarantoolRecover    6292 ns/op\t     563 B/op\t   10 allocs/op\n"})}),"\n",(0,o.jsx)(n.p,{children:"Tarantool can provide new storage properties (like synchronous replication), new adoption. We are pretty excited about adding it as an option."}),"\n",(0,o.jsxs)(n.p,{children:["The reason why Tarantool support is experimental is because Tarantool integration involves one more moving piece \u2013 the ",(0,o.jsx)(n.a,{href:"https://github.com/centrifugal/tarantool-centrifuge",children:"Centrifuge Lua module"})," which should be run by a Tarantool server."]}),"\n",(0,o.jsxs)(n.p,{children:["This increases deployment complexity and given the fact that many users have their own best practices in Tarantool deployment we are still evaluating a sufficient way to distribute Lua part. For now, we are targeting standalone (see examples in ",(0,o.jsx)(n.a,{href:"https://github.com/centrifugal/tarantool-centrifuge",children:"centrifugal/tarantool-centrifuge"}),") and Cartridge Tarantool setups (with ",(0,o.jsx)(n.a,{href:"https://github.com/centrifugal/rotor",children:"centrifugal/rotor"}),")."]}),"\n",(0,o.jsxs)(n.p,{children:["Refer to the ",(0,o.jsx)(n.a,{href:"/docs/server/engines#tarantool-engine",children:"Tarantool Engine documentation"})," for more details."]}),"\n",(0,o.jsx)(n.h3,{id:"grpc-proxy",children:"GRPC proxy"}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo can now transform events received over persistent connections from users into GRPC calls to the application backend (in addition to the HTTP proxy available in v2)."}),"\n",(0,o.jsx)(n.p,{children:"GRPC support should make Centrifugo ready for today's microservice architecture where GRPC is a huge player for inter-service communication."}),"\n",(0,o.jsx)(n.p,{children:"So we mostly just provide more choices for Centrifugo users here. GRPC has some good advantages \u2013 for example an application backend RPC layer which is responsible for communication with Centrifugo can now be generated from Protobuf definitions for all popular programming languages."}),"\n",(0,o.jsx)(n.h3,{id:"server-api-improvements",children:"Server API improvements"}),"\n",(0,o.jsx)("img",{src:"/img/test-tube.svg",align:"right",width:"25%"}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo v3 has some valuable server API improvements."}),"\n",(0,o.jsxs)(n.p,{children:["The new ",(0,o.jsx)(n.code,{children:"subscribe"})," API method allows subscribing connection to a channel at any point in t
1ime. This works by utilizing server-side subscriptions. So it's not only possible to subscribe connection to a list of server-side channels during the connection establishment phase \u2013 but also later during the connection lifetime. This may be very useful for the unidirectional approach - by emulating client-side subscribe call over request to application backend which in turn calls subscribe Centrifugo server API."]}),"\n",(0,o.jsx)(n.p,{children:"Publish API now returns the current top stream position (offset and epoch) for channels with history enabled."}),"\n",(0,o.jsx)(n.p,{children:"Server history API inherited iteration possibilities described above."}),"\n",(0,o.jsx)(n.p,{children:"Channels command now returns a number of clients in a channel, also supports channel filtering by a pattern. Since we changed how channels call implemented internally there is no limitation anymore to call it when using Redis cluster."}),"\n",(0,o.jsxs)(n.p,{children:["Admin web UI has been updated too to support new API methods, so you can play with new API from its ",(0,o.jsx)(n.code,{children:"actions"})," tab."]}),"\n",(0,o.jsx)(n.h3,{id:"better-clustering",children:"Better clustering"}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo behaves a bit better in cluster mode: as soon as a node leaves a cluster gracefully (upon graceful termination) it sends a shutdown signal to the control channel thus giving other nodes a chance to immediately delete that node from the local registry."}),"\n",(0,o.jsx)(n.h3,{id:"client-improvements",children:"Client improvements"}),"\n",(0,o.jsx)(n.p,{children:"While preparing the v3 release we improved client connectors too. All existing client connectors now actualized to the latest protocol, support server-side subscriptions, history API."}),"\n",(0,o.jsxs)(n.p,{children:["One important detail is that it's not required to set ",(0,o.jsx)(n.code,{children:"?format=protobuf"})," URL param now when connecting to Centrifugo from mobile devices - this is now managed internally by using the WebSocket subprotocol mechanism (requires using the latest client connector version and Centrifugo v3)."]}),"\n",(0,o.jsx)(n.h3,{id:"new-documentation-site",children:"New documentation site"}),"\n",(0,o.jsxs)(n.p,{children:["You are reading this post on a new project site. It's built with amazing ",(0,o.jsx)(n.a,{href:"https://docusaurus.io/",children:"Docusaurus"}),"."]}),"\n",(0,o.jsx)(n.p,{children:"A lot of documents were actualized, extended, and rewritten. We also now have new chapters like:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"/docs/getting-started/highlights",children:"Main highlights"})}),"\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"/docs/getting-started/design",children:"Design overview"})}),"\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"/docs/server/history_and_recovery",children:"History and recovery"})}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.a,{href:"/docs/server/codes",children:"Error and disconnect codes"}),"."]}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"Server API and proxy documentation have been improved significantly."}),"\n",(0,o.jsx)(n.h3,{id:"performance-improvements",children:"Performance improvements"}),"\n",(0,o.jsx)("img",{src:"/img/stopwatch.svg",align:"right",width:"25%"}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo v3 has some notable performance improvements."}),"\n",(0,o.jsxs)(n.p,{children:["JSON client protocol now utilizes a couple of libraries (",(0,o.jsx)(n.code,{children:"easyjson"})," for encoding and ",(0,o.jsx)(n.code,{children:"segmentio/encoding"})," for unmarshaling). Actually we use a slightly customized version of ",(0,o.jsx)(n.code,{children:"easyjson"})," library to achieve even faster performance than it provides out-of-the-box. Changes allowed to speed up JSON encoding and decoding up to 4-5x for small messages. For large payloads speed up can be even more noticeable \u2013 we observed up to 30x performance boost when serializing 5kb messages."]}),"\n",(0,o.jsx)(n.p,{children:"For example, let's look at a JSON serialization benchmark result for 256 byte payload. Here is what we had before:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:'title="Centrifugo v2 JSON encoding/decoding"',children:"cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\nBenchmarkMarshal-12              \t 5883 ns/op\t    1121 B/op\t    6 allocs/op\nBenchmarkMarshalParallel-12      \t 1009 ns/op\t    1121 B/op\t    6 allocs/op\nBenchmarkUnmarshal-12            \t 1717 ns/op\t    1328 B/op\t   16 allocs/op\nBenchmarkUnmarshalParallel-12    \t492.2 ns/op\t    1328 B/op\t   16 allocs/op\n"})}),"\n",(0,o.jsx)(n.p,{children:"And what we have now with mentioned JSON optimizations:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",metastring:'title="Centrifugo v3 JSON encoding/decoding"',children:"cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\nBenchmarkMarshal-12              \t 461.3 ns/op\t 928 B/op\t    3 allocs/op\nBenchmarkMarshalParallel-12      \t 250.6 ns/op\t 928 B/op\t    3 allocs/op\nBenchmarkUnmarshal-12            \t 476.5 ns/op\t 136 B/op\t    3 allocs/op\nBenchmarkUnmarshalParallel-12    \t 107.2 ns/op\t 136 B/op\t    3 allocs/op\n"})}),"\n",(0,o.jsx)(n.admonition,{type:"tip",children:(0,o.jsx)(n.p,{children:"Centrifugo Protobuf protocol is still faster than JSON for encoding/decoding on a server-side."})}),"\n",(0,o.jsx)(n.p,{children:"Of course, JSON encoding is only one part of Centrifugo \u2013 so you should not expect overall 4x performance improvement. But loaded setups should notice the difference and this should also be a good thing for reducing garbage collection pauses."}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo inherited a couple of other improvements from the Centrifuge library."}),"\n",(0,o.jsxs)(n.p,{children:["In-memory connection hub is now sharded \u2013 this should reduce lock contention between operations in different channels. In ",(0,o.jsx)(n.a,{href:"https://github.com/centrifugal/centrifuge/pull/184",children:"our artificial benchmarks"})," we noticed a 3x better hub throughput, but in reality the benefit is heavily depen
1ds on the usage pattern."]}),"\n",(0,o.jsx)(n.p,{children:"Centrifugo now allocates less during message broadcasting to a large number of subscribers."}),"\n",(0,o.jsx)(n.p,{children:"Also, an upgrade to Go 1.17 for builds results in ~5% performance boost overall, thanks to a new way of passing function arguments and results using registers instead of the stack introduced in Go 1.17."}),"\n",(0,o.jsx)(n.h3,{id:"centrifugo-pro",children:"Centrifugo PRO"}),"\n",(0,o.jsx)(n.p,{children:"The final notable thing is an introduction of Centrifugo PRO. This is an extended version of Centrifugo built on top of the OSS version. It provides some unique features targeting business adopters."}),"\n",(0,o.jsx)(n.p,{children:"Those who followed Centrifugo for a long time know that there were some attempts to make project development sustainable. Buy me a coffee and Opencollective approaches were not successful, during a year we got ~300$ of total contributions. While we appreciate these contributions a lot - this does not fairly justify a time spent on Centrifugo maintenance these days and does not allow bringing it to the next level. So here is an another attempt to monetize Centrifugo."}),"\n",(0,o.jsxs)(n.p,{children:["Centrifugo PRO details and features described ",(0,o.jsx)(n.a,{href:"/docs/pro/overview",children:"here in docs"}),". Let's see how it goes. We believe that a set of additional functionality can provide great advantages for both small and large-scale Centrifugo setups. PRO features can give useful insights on a system, protect from client API misusing, reduce server resource usage, and more."]}),"\n",(0,o.jsx)(n.p,{children:"PRO version will be released soon after Centrifugo v3 OSS."}),"\n",(0,o.jsx)(n.h3,{id:"conclusion",children:"Conclusion"}),"\n",(0,o.jsx)(n.p,{children:"There are some other changes introduced in v3 but not mentioned here. The full list can be found in the release notes and the migration guide."}),"\n",(0,o.jsx)(n.p,{children:"Hope we stepped into an exciting time of the v3 life cycle and many improvements will follow. Join our communities in Telegram and Discord if you have questions or want to follow Centrifugo development:"}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.a,{href:"https://t.me/joinchat/ABFVWBE0AhkyyhREoaboXQ",children:(0,o.jsx)(n.img,{src:"https://img.shields.io/badge/Telegram-Group-orange?style=flat&logo=telegram",alt:"Join the chat at https://t.me/joinchat/ABFVWBE0AhkyyhREoaboXQ"})})," \xa0",(0,o.jsx)(n.a,{href:"https://discord.gg/tYgADKx",children:(0,o.jsx)(n.img,{src:"https://img.shields.io/discord/719186998686122046?style=flat&label=Discord&logo=discord",alt:"Join the chat at https://discord.gg/tYgADKx"})})]}),"\n",(0,o.jsx)(n.p,{children:"Enjoy Centrifugo v3, and let the Centrifugal force be with you."}),"\n",(0,o.jsxs)(n.admonition,{title:"Special thanks",type:"note",children:[(0,o.jsxs)(n.p,{children:["Special thanks to ",(0,o.jsx)(n.a,{href:"https://github.com/silischev",children:"Anton Silischev"})," for the help with v3 tests, examples and CI. To ",(0,o.jsx)(n.a,{href:"https://github.com/leeoniya",children:"Leon Sorokin"})," for the spinning CSS Centrifugo logo. To ",(0,o.jsx)(n.a,{href:"https://github.com/filonenko-mikhail",children:"Michael Filonenko"})," for the help with Tarantool. To ",(0,o.jsx)(n.a,{href:"https://github.com/mogol",children:"German Saprykin"})," for Dart magic."]}),(0,o.jsx)(n.p,{children:"Thanks to the community members who tested out Centrifugo v3 beta, found bugs and sent improvements."}),(0,o.jsxs)("div",{children:["Icons used here made by ",(0,o.jsx)("a",{href:"https://www.flaticon.com/authors/wanicon",title:"wanicon",children:"wanicon"})," from ",(0,o.jsx)("a",{href:"https://www.flaticon.com/",title:"Flaticon",children:(0,o.jsx)(n.a,{href:"http://www.flaticon.com",children:"www.flaticon.com"})})]})]})]})}function d(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(h,{...e})}):h(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.