ubuntips

What open WebSockets cost a XenForo server

Draft posted on · 6 min read

On this page
Draft commented on Dec 2, 2026

When I added Centrifugo to my setup script, I left one question open. The gate for every change to the script is that no XenForo page tier loses requests per second or p99. That gate exists so a release can’t quietly make the forum slower. Centrifugo is different from a compiler flag or an nginx option, though. It’s a new opt-in service that runs next to the forum. So the question isn’t whether the code got slower; it’s what the forum gives up while thousands of member sockets are open on the same box.

This post answers the throughput half of that question, on the Xeon E-2236 test host. Page p99 with sockets open is still unmeasured.

The method#

  • The same XenForo page tiers I use for every A/B (loopback-tiers.sh, 100 connections, 10 s per tier): cached guest home and thread pages, and logged-in member home and thread pages.
  • Each tier run twice: once with no sockets, and once with member sockets held open through nginx by the WebSocket load generator, with publishes flowing the whole time.
  • The same Centrifugo setup as the original load test: the memory engine, the verified release binary, nginx with the 8k tunnel buffers.
  • 3 rounds with the order rotated, the clock pinned at 3.6 GHz, medians reported.

One thing shapes every number below. The load generator that holds the sockets ran on the same 12-thread box as nginx, PHP, MariaDB and Centrifugo. Its CPU time counts against the pages. A real forum’s sockets come from members’ browsers, not from a process on the server, so each drop below is an upper bound on what Centrifugo costs.

The realistic run: 4,000 sockets#

4,000 sockets is a normal peak for my largest boards, and 10,000 is about the most they reach. One socket is one open member tab; guests never connect. For the publish rate I used 5 thread and 5 personal publishes per second, ten messages a second.

Every message was delivered, at a p50 of 3 ms and a p99 of 12 ms.

Tierno sockets (req/s)4,000 sockets (req/s)change
guest home (cached)144,261142,090-1.5 %
guest thread (cached)106,975104,359-2.4 %
member home351338-3.7 %
member thread232228-1.7 %

So at a normal peak, the pages lost 1.5 to 3.7 % of their requests per second, and that includes the load generator’s own CPU. On this rig, that’s the most the feature cost a forum that uses it.

The stress run: 10,000 sockets#

To see where the box runs out, I repeated it at 10,000 sockets with the original load test’s publish rate: 100 thread and 20 personal publishes per second. With every thread publish fanned out to that channel’s subscribers, that’s about 50,000 WebSocket frames a second through nginx.

Tierno sockets (req/s)10,000 sockets (req/s)change
guest home (cached)145,400-147,73895,791-107,821about -27 %
member home338-339222-233about -32 %

That’s a big drop, and it isn’t a regression. It’s twelve threads running nginx, PHP-FPM, MariaDB, Centrifugo and a load generator pushing 50,000 frames a second, all at once. The pages lose what the other work takes. On a host that doesn’t run --centrifugo, nothing changes: the service is opt-in, and without it there is no unit, no nginx location and no booked memory.

Why this passes the gate#

The gate asks whether a change makes the same work slower. Hosts without --centrifugo don’t run the service at all, so for them nothing changes. On a host with it, the server is doing more work, and the right question is whether that cost is acceptable. At a realistic peak it’s under 4 % of requests per second with a pessimistic rig. At twelve times the realistic publish rate and 2.5 times the sockets, it’s about a third, which tells you where this box’s capacity is, not that something got worse. That covers throughput; whether page p99 holds with sockets open is the part I haven’t measured.

What to plan for#

  • Size for peak members online, not for total members. One socket is one open member tab. conns=auto plans 10,000, and conns=N plans more. That number sizes file limits, nginx’s connection table and the memory booking.
  • Watch the delivery rate, not just the socket count. Each open socket costs memory: about 43 KB in Centrifugo and 29 KB in nginx, from the original load test. The frames the server delivers are roughly posts per second times the subscribers of each thread. Ten publishes a second to 4,000 sockets cost the pages 1.5 to 3.7 %. 120 a second to 10,000, about 50,000 frames, cost 27 to 32 %. Both the sockets and the rate went up between those runs, so I can’t yet say how much of the cost is the rate and how much is the socket count.
  • A hot thread means more frames. A thread with thousands of readers watching it, while replies come in every second, generates far more frames than the same number of members spread across quiet threads. I didn’t benchmark one thread against many; this is the arithmetic of fan-out.
  • If a board really runs at that rate, a smaller socket limit isn’t the fix. It cuts members off. More cores are the likely answer, but I haven’t tested a bigger box.

What I didn’t measure#

  • Sockets and rate separately. The stress run raised the socket count (4,000 to 10,000) and the publish rate (10 to 120 a second) together. So I can’t split the cost between the two. A run with 10,000 idle sockets, and one with 4,000 sockets at 120 publishes a second, would settle it.
  • A load generator on a separate machine. All drops above include its CPU. With the sockets coming from elsewhere, the real cost should be lower, by an amount I haven’t measured.
  • Thread pages at 10,000. The stress run recorded only the guest home and member home tiers, not the guest thread or member thread tiers.
  • p99 for the page tiers. This run compared requests per second only. The gate also covers p99, and page latency with sockets open is still open.
  • Through Cloudflare or a front proxy. Everything here was on the origin over loopback.
  • AMD. Everything above ran on the Xeon. Nothing ran on the AMD EPYC 7401P (Zen 1) server.

For a forum at its normal peak, live posts, typing and presence cost the pages under 4 % of their throughput on this rig. At a much higher publish rate with more sockets, the cost was about a third, so plan from your busiest threads and peak members online, not from the total member count.

Back to top ↑