ubuntips

Centrifugo on its memory engine or on Valkey

Draft posted on · 5 min read

On this page
Draft commented on Dec 2, 2026

When I added Centrifugo to my setup script, it was built with two engines. The default keeps channels, presence and history in Centrifugo’s own memory. The other, engine=valkey, pointed Centrifugo’s Redis engine at the Valkey the script already runs for XenForo. The instruction for it was simple: pair Valkey with Centrifugo if it improves performance. This post covers why the first build never started, the A/B that followed, and why engine=valkey is now removed.

The unix socket that wasn’t#

The script runs Valkey on a unix socket only, so the first build of engine=valkey gave Centrifugo a unix:// address for it. Centrifugo 6.10.4 accepts that kind of address, but the service never started; it failed with a dial tcp ... missing port error.

Centrifugo 6.10.4 accepts the unix:// address but then dials every Redis address over TCP, whatever the address says. So in this version there is no way to reach Redis or Valkey over a unix socket. Every address goes out over TCP.

Nothing broke on the server. The script keeps a new Centrifugo configuration only if the service starts and answers /health, and this one didn’t, so the run rolled back to the memory-engine configuration, which kept serving.

The method#

To still answer the question, I ran the Redis engine against a throwaway Valkey 9.2.1 on 127.0.0.1:16379, with no persistence, on the test host only, and removed it afterwards. Everything else matched the load test that set the defaults:

  • Xeon E-2236 test host, Centrifugo 6.10.4 behind nginx with the 8k tunnel buffers
  • 4,000 and then 10,000 member sockets through nginx, each on one of 20 thread channels plus its own personal channel
  • 100 thread publishes and 20 personal publishes per second for 60 s
  • 3 rounds per engine, with the order rotated each round
  • the load generator on the same host

The numbers#

Engine4,000 sockets p50 / p9910,000 p50 / p99 (3 rounds)10,000 deliveredCentrifugo CPU at 10k
memory2.5-2.6 / 4.7 ms35-37 / 138, 171, 1,356 ms100 % every round0.73-0.77 cores
Valkey (TCP)2.6-2.7 / 4.8-4.9 ms7 / 282, 493, 8,799 ms100, 100, 96.2 %1.01-1.54 cores (+ Valkey 0.05-0.07)

At 4,000 sockets the two engines are the same within noise.

At 10,000 the Valkey engine has the lower median, 7 ms against 35-37 ms. Everything else went the other way. Its p99 was worse in every round, by 2-3x in the first two and 6.5x in the third. Centrifugo used up to twice the CPU, plus a little for Valkey itself. And in one round it lost 3.8 % of the messages, while the memory engine delivered every message in every round.

A forum reader doesn’t notice a median of 7 ms against 36 ms for a new post appearing. They do notice a post that arrives seconds late or never arrives. A better median doesn’t make up for a worse tail and lost messages.

Why it’s removed and not just off#

My rule for a default is at least 2 % faster somewhere and slower nowhere. The Valkey engine isn’t faster where it counts, so it was never going to become the default. I also removed it as an option, for two reasons:

  • The only working path is TCP. To use it on a real server, the script would have to open a TCP port on Valkey. That Valkey has no password; today it is reached only through its unix socket. A password-less TCP listener, even on loopback, is something every local process can reach, and I don’t want the script to create that.
  • An option nobody should pick is still code to test. It would keep a second configuration path, a second rollback case and a second set of tests alive for no benefit.

So engine=valkey is gone. setup.sh --centrifugo always uses Centrifugo’s in-process memory engine, and Valkey stays on its unix socket only.

This is a single-node answer#

The memory engine works because one Centrifugo serves every socket. With two or more Centrifugo nodes, a message published on one node has to reach sockets on the others, and that needs a shared broker such as Redis or Valkey. The memory engine can’t do that.

That isn’t my case. My largest boards peak near 10,000 members online, which one node handles, as the table shows. If a board ever outgrows one node, the engine question comes back, and it would need a fresh measurement on whatever Centrifugo version is current then.

What I didn’t measure#

  • Valkey over a unix socket. Centrifugo 6.10.4 can’t use one, so I couldn’t test it. A later version that dials unix sockets properly could change the result, and I’d re-run the A/B then.
  • More than three rounds. The p99 at 10,000 varied a lot between rounds for both engines (138 to 1,356 ms for memory). Three rounds show which engine has the worse tail, but not a precise number for it.
  • Load generator separate from the server. It ran on the same host, competing for the same CPUs, as in the earlier load test. That probably inflates the 10,000-socket numbers for both engines.
  • AMD. Everything above ran on the Xeon. Nothing ran on the AMD EPYC 7401P (Zen 1) server.
  • More than one node. That’s the case where a broker is required, and I don’t run it.

Back to top ↑