Centrifugo v1.5.0 just released! As you may know this is a real-time messaging server written in Go.
This release contains a lot of internal refactoring, Centrifugo now uses gogo/protobuf library for serializing messages going between Centrifugo nodes (when using Redis). Also some message types were refactored to get rid of some empty interface{}
usages left.
The goal of this release was to improve performance of the most frequently used API operation - publishing new message into channel. A lot of CPU time before went to encoding every new message into JSON (as Centrifugo mostly works with web JSON is the obvious choice for client protocol).
So I tried several libraries that could speed up JSON encoding - ffjson, easyjson. They worked as expected. But then I realized that the biggest speed up will be if we stop serializing every message into JSON. So I replaced JSON encoding on gogoprotobuf
(which is really fast) based encoding for messages between Centrifugo nodes and presence/history data (when using Redis-based engine). And refactored internal engine to be more flexible. This way we now only serialize into JSON when we have client connected to node. And marshal JSON manually using pool of buffers - so this almost does not allocate memory.
The next step can be also improve performance of unmarshaling API requests (which are also a JSON). I did several experiments with jsonparser and its EachKey API in particular and got nice results - less allocations and better performance.
Other changes include using latest version of SockJS by default (1.1.1 at moment). Also it worth noting that during last months we got Android and iOS clients contributed by open-source community members so Centrifugo now covers web and mobile application development which is pretty good I think.