Related posts
- clang, PHP 8.4 and the missing zlib: the last round of compiled PHP
The final round of the compiled-PHP question: CentminMod's function alignment on its own, a clang build and PHP 8.4, with every module compiled from source. clang is the only build with a repeatable edge (+3 % on XenForo), 8.4 is slower than 8.5, and my earlier source builds were missing zlib.
- Who compresses a logged-in XenForo page? 12 % of PHP, one fastcgi_param, and a clock that lied
Profiling the member pages of a XenForo forum showed zlib eating 12 % of PHP-FPM CPU: XenForo gzips its own pages at level 9 inside the worker. Moving that to Angie gave +5 % on the forum index and +9 % on thread pages. Along the way, a CPU turbo budget faked a 27 % speed-up, and three other ideas did not survive measurement.
- Everything on: LTO, PGO and -march=native made PHP 8.5 slower
A follow-up to the four-build PHP test: turn on every CentminMod compiler option, add LTO and two-stage PGO trained on real XenForo traffic, and compile every module from source. The result is 5 to 10 % slower than the distribution package, not faster.
The question for this round was simple: what is the fastest way to serve a large XenForo forum on one server? My setup runs Angie in front of PHP-FPM, with a FastCGI page cache for guests. The usual answer from the LiteSpeed side is OpenLiteSpeed: its own PHP interface (LSAPI) and a built-in page cache, LSCache, which XenForo can use through the official LiteSpeed Cache add-on. I had left OpenLiteSpeed out of earlier shootouts because, without that add-on, it has no page cache for XenForo at all. With the add-on, it gets a fair fight.
Short version: Angie serves cached guest pages 16-23 % faster. Logged-in members are a tie. Under overload, Angie treats every visitor the same, while OpenLiteSpeed makes some of them wait for seconds. And the add-on, set up the way its documentation says, shows logged-in members the cached guest page.
The four setups#
All four run on the same Xeon E-2236 test host (6 cores, 12 threads) with the same PHP 8.5.13, the same
php.ini(OPcache 512 MB, tracing JIT), 12 PHP processes, the same TLS certificate and the same forum.-O3 -march=nativeThe forum was grown with a seeder to 20,000 users, 10,200 threads and 103,000 posts, so the member pages do real database work. The load came from
wrkon the same machine. Every round ran each setup in turn (the order reversed every other round), the guest caches were emptied before each one, and the CPU clock was pinned at 3.6 GHz, because this CPU’s turbo fades under load and would otherwise favour whoever goes first.Getting OpenLiteSpeed to a fair start#
OpenLiteSpeed needed three changes before the numbers meant anything, and none of them is obvious:
www-data, which owns the forum files. OpenLiteSpeed won’t launch PHP processes for a user ID below 100 unless you lowerminUID, so every request was a 503.The add-on’s documented setup shows members the guest page#
The LiteSpeed Cache add-on for XenForo works with a few rewrite rules: look the request up in the cache, and store the page unless the visitor has a member cookie. The add-on itself sets a marker cookie when someone logs in.
The catch is the lookup.
CacheLookup onserves the stored guest copy to any request that matches. The marker cookie only exists for logins made after the add-on was installed. A member who logged in earlier, or who comes back through XenForo’s “stay logged in” cookie, doesn’t have it. Testing with exactly such a member returnedx-litespeed-cache: hitand a page with no logged-in user on it.This is not a privacy leak. The add-on never lets a logged-in page be stored, so nobody sees another member’s page. But members see a logged-out forum, and in a benchmark every “member” request would actually measure the cache. One extra rule fixes it, placed before the lookup:
The cache key now includes XenForo’s session cookies, so a member’s request never matches the guest copy and goes to PHP, as it does through Angie. A “no-cache” rule before or after the lookup did not help; the vary did.
Guests: Angie is clearly faster#
Median of five rounds, requests per second, 100 connections:
The result was the same at 400 connections. Measured per cached hit, OpenLiteSpeed spends 14-22 % more CPU than Angie (0.077 ms against 0.063 ms on the index), and it never got the machine past about 10 of its 12 threads. On a big forum most traffic is guests and crawlers, so this is the number that decides how much the server can take.
The PHP build makes no difference here, as expected: a cache hit never reaches PHP.
Members: a tie, once the benchmark was honest#
The first matrices gave OpenLiteSpeed a 6-9 % lead on member pages. That looked like a real point in its favour, so I measured it again and found two problems in my own harness:
Measured again, with the machine clean between setups and the two servers alternating:
The thread page is a tie. The index is right at the 3 % line I use as the noise threshold. The CPU per page is the same: 47.6 ms for Angie plus PHP-FPM against 47.9 ms for OpenLiteSpeed plus lsphp. Compression isn’t the difference either: Angie’s gzip costs the same as its brotli on these pages.
Under overload, one stack is fair and the other isn’t#
There is one more difference, and
wrkhides it.wrkonly records how long finished requests took. So I ran the member load at full saturation and, alongside it, timed 150 page loads from a separate client, the way a new visitor would see them:Angie and PHP-FPM serve requests in the order they arrive. When the server is saturated, everyone waits about the same 0.45 s. OpenLiteSpeed keeps about a dozen connections moving fast and parks the rest. Most visitors get a quick page, but a parked one waits seconds, and 4 of 300 probe requests were still waiting when they gave up after 30 seconds. On a busy forum, those are the people who leave. Angie wasn’t perfect either: three of its four runs (counting the clang build) had one request that came back with an error after 7-9 seconds, which I haven’t explained yet.
Verdict#
I’m keeping Angie, PHP-FPM and the FastCGI cache.
If you already run OpenLiteSpeed with the XenForo add-on, add the
cache-varyline above and check your keep-alive setting.What else changed this cycle#
The audit this time ran in two rounds, and every finding was checked by independent reviewers who tried to prove it wrong. The second round reviewed this cycle’s own changes and caught one of them before it shipped.
\vsso_token=…reached PHP as a login cookie the cache never saw, and the page was stored for every guest. On the test host, the second such request filled the cache, and the next normal visitor got that copy. Any cookie header with a control character now skips the cache.--domaincan no longer leave the site down. The final tuning pass ran in a subshell where a paused web server was invisible to the cleanup code./etc/hostsno longer gains a blank line with every install and restore. That small drift had been open for three cycles. The cause turned out to be cloud-init: it rewrites/etc/hostsat the first boot after the server is renamed, and the restore then merged instead of restoring the original, keeping the blank line cloud-init left.