Related posts
- Setup script 1.22.5, before and after: XenForo 17-32 % faster on the same box
I benchmarked the whole 1.22.5 release against 1.22.4 the way a server gets it: an --optimize run, a reboot, then load. Cached XenForo pages went from 122k to 161k req/s, uncached pages 17-22 % faster, p99 14-20 % lower, and PHP-FPM uses half the memory. Most of it is the kernel; the rest is a new allocator for PHP, a lower Brotli level and AWS-LC under nginx. The benchmark also caught a bug that would have stopped every updated server from rebuilding PHP.
- XenForo on PHP 8.1 to 8.6: the same build six times
Six PHP series compiled with the same clang recipe and the same extensions, one XenForo forum with 100,000 posts, plain nginx, PHP-FPM and MariaDB. PHP 8.5 and 8.6 serve uncached pages 8-11 % faster than 8.1. 8.2, 8.3 and 8.4 tie, and 8.6 adds nothing over 8.5 yet.
- 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.
My setup script compiles nginx, PHP and Valkey from source and tunes them to the hardware it runs on. This cycle had a short list from me: try the trim filter from Tengine, make a few remaining options automatic, and stop
--optimizefrom looking frozen while it compiles. The audit that went with it found a real security bug too.Does stripping whitespace from HTML pay?#
Tengine, Alibaba’s nginx fork, ships
ngx_http_trim_filter_module: it collapses runs of spaces and newlines in HTML and drops comments, leaving<pre>,<textarea>and (by default) inline scripts and styles alone. It sounds like free bandwidth. The module still compiles against current nginx mainline (1.31.10) as a static module, so I built it from Tengine 3.1.0, pinned by commit and checksum, into two otherwise identical nginx binaries: same recipe, same compiler flags, neither post-link optimised, so the pair differs only by the module.Two details decide everything:
What it saves: a member’s forum index went from 17,695 to 16,471 bytes with gzip (-6.9 %) and from 21,516 to 19,380 with Brotli (-9.9 %); a long thread page 7-8 %. Uncompressed, 12-15 %. Pages rendered the same; after normalising whitespace, the only differences were per-request tokens.
What it costs, on a Xeon E-2236 test box (6 cores, 12 threads) with a XenForo 2.3.14 forum seeded with 20,000 members, 10,000 threads and 100,000 posts. Three rounds, arms rotated, CPU clock pinned at 3.6 GHz:
On every PHP-rendered page the slowest trim round was below the fastest run without it. My rule for a new default is at least 2 % faster somewhere and slower nowhere, so this is a clear no. The bytes it saves are also bytes a CDN in front of the server compresses again at the edge.
To trim the cached guest pages too, XenForo’s gzip has to go, and then nginx compresses every cache hit instead of sending a stored, already-compressed body. That arm is the real lesson of the run: cached throughput fell from about 142,000 to 16,000 requests per second without the filter, and to 9,000 with it. Storing the pre-compressed page is what makes a cache hit cheap; anything that has to touch the body on every hit gives that away.
Four more ideas, four defaults confirmed#
With every binary optimised with BOLT from live traffic (worth about 8 % on the PHP pages against the same build without it), I put the current defaults against their obvious alternatives:
Nothing changes. Recording a loss is still worth a run: the next time someone suggests “just give PHP more workers”, the number is here.
Five options that should not have been options#
--basictookserver=dedi|vps,swap=andmitigations=;--phptookchildren=andmax_requests=. Every one of them already had an automatic value, and--optimizealready ignored them and recomputed from the hardware. So an install with one of them produced a server that the next--optimizesilently changed. They are gone: the server type is detected on every run, swap is half the RAM between 1 and 8 GB, CPU mitigations stay off (my standing choice for single-tenant, key-only servers), and the PHP pool is one static worker per logical CPU on a local database with flash storage. A command that still passes one of them stops with the release that removed it, before anything changes. Taking the explicit worker count out also removed a whole branch of the memory planner.“Is it stuck?”#
--optimizerebuilds nginx, PHP or Valkey when a new release, a new CPU or a new set of PHP extensions makes the binary stale, and a PHP build takes several minutes. Until now the terminal showed “Optimizing installed services” and then nothing, because every build step went only into the final report. Now each step prints as it starts, with what is serving and why it is replaced:A line every 30 seconds names the step, the elapsed time and the log to tail. The same goes for the BOLT passes, which sample a minute of live traffic each. The example above is real: the first
--optimizeafter XenForo was uploaded found that the SV RedisCache add-on needs theredisandigbinaryextensions and rebuilt PHP with them.A nightly chown that root could be tricked into#
Every night the script’s cron job made everything under
/var/wwwowned by the web user, withfind /var/www ... -exec chown -h www-data:www-data {} +.-hstops chown from following a symlink in the last part of the path, butfindhands chown full paths, and chown resolves every directory in them again. A compromised PHP application runs as that web user and owns those directories. It could swap a directory for a symlink to/etcbetween find’s read and the chown, and root would hand it/etc/shadow. The job now uses-execdir, which runs chown from inside each file’s own directory on./name, and only touches files that are not already owned by the web user. It needs a compromised application first, but it turns that into root.The same review tightened the XenForo guest cache. Only the front controller (
index.php) feeds it now; before, a guest’s GET to any other PHP script, an add-on’s callback orjob.php, could be stored for five minutes and its side effect skipped on every hit. An AJAX request (XenForo’s JavaScript setsX-Requested-With) is never served from it, and a response that starts a XenForo session is never stored. Measured against the old configuration on the same server, every page type stayed within noise (+0.7 % and -0.9 % on the cached pages over five rounds).Smaller things#
--optimizereally does when one service’s tuning fails: it marks that service FAILED, carries on with the others and exits non-zero. It no longer claims the run aborts.The test box went back to its recorded clean state afterwards: same 701 packages, apart from ten newer versions from Ubuntu’s own security updates.