All posts

PHP 8.6 Performance Benchmark: The php-fpm Image Is Thread-Safe, and That Costs 2%

November 26, 2026Michał Woliński48 min read
PHP 8.6 Performance Benchmark: The php-fpm Image Is Thread-Safe, and That Costs 2%

PHP 8.6.0 came out on 19 November 2026, and the first thing many people will do is change php:8.5-fpm to php:8.6-fpm in a Dockerfile. I did that to a Laravel and a Symfony application and measured what changes, on an x86_64 server and on an arm64 MacBook. On the server the 8.6 image served 1.5 to 2.6% fewer requests per second on all four endpoints, which is small but consistent: the 8.5 rounds of one endpoint differ from each other by at most 8.2%. The slowdown is not the version. The official 8.6 images are built thread-safe (ZTS) and the 8.5 ones are not, and a control that separates the two puts the cost on the build: 8.6 built without thread safety is 1.6 to 1.8% faster than 8.5, and 8.6 built thread-safe is 1.0 to 2.6% faster than 8.5 built thread-safe.

On the MacBook the same test says 8.6 is between 2.4% faster and 9.9% slower. The sign agrees with the server on three of the four endpoints, but I would not quote the size: the 8.5 rounds of one endpoint span 26 to 59% there, against at most 8.2% on the server. On the command line nothing moved on either machine: PHPStan, Composer's autoload dump, Symfony's cache:clear, ten Laravel artisan list calls and a CPU-bound micro suite took the same time within the spread, with identical results on every image.

Short answer for an architect: the speed cost of moving php-fpm to 8.6 is a couple of percent on a quiet server, and the cause is the thread-safe build, not the version. The more expensive consequences of that build are not about speed: an extension compiled for the non-thread-safe PHP will not load, and max_execution_time now counts waiting. Check those two before you change the tag.

What I ranx86_64 serverarm64 MacBook
php-fpm, 8.6.0 image against the 8.5.13 image1.5 to 2.6% slower, 8 rounds9.9% slower to 2.4% faster, ranges overlap
php-cgi, the version alone (8.6 NTS against 8.5 NTS)1.6 to 1.8% faster3.4 to 15.4% faster, within the spread
php-cgi, what thread safety costs (8.5 ZTS against 8.5 NTS)2.4 to 5.2% slower6.7% slower to 3.1% faster, within the spread
CLI: PHPStan, Composer, Symfony cache, artisanwithin 7.8% on every workloadwithin 14% on every workload (spread up to 175%)
CPU micro suite, 7 cases (NTS builds)within 3.9%within 5.1%

Medians of five or eight rounds, with the builds taking turns going first. The raw rounds of every series are in the repository behind this article, for the server in runs/v2-server and for the MacBook in runs/v2-mac; the links below point at one fixed commit, so they do not move. Since 25 November the official images also have a php:8.6.0-nts tag, which is what makes the control possible: until then there was no official 8.6 without thread safety to compare against. My earlier article on PHP 8.6 lists what the release changes; this one is only about speed.

What was compared

All images are the official ones from Docker Hub, Debian trixie variants. Six of them took part:

ImagePHPThread safetymbstringUsed for
php:8.5.13-fpm8.5.13NTSyesphp-fpm series
php:8.6.0-fpm8.6.0ZTSnophp-fpm series
php:8.5.13-cli8.5.13NTSyesphp-cgi, php -S, CLI: 8.5 without thread safety
php:8.5.13-zts8.5.13ZTSyescontrol: 8.5 with thread safety
php:8.6.0-nts8.6.0NTSnocontrol: 8.6 without thread safety
php:8.6.0-cli8.6.0ZTSnophp-cgi, php -S, CLI: 8.6 as shipped

The thread safety of the 8.6 images is a choice, not an accident of my setup. The 8.6 Dockerfile passes --enable-zts and --disable-zend-signals for the default variants, while the 8.5 Dockerfile does not, and it still passes --enable-mbstring where 8.6's does not (both as read on 25 November 2026, saved as 8.5 and 8.6). The reasons are argued in docker-library's issues #1673 and #1719 (title: "Reconsider ZTS-only builds for 8.6 until upstream PHP has actually decided", opened on release day and closed after 56 comments). On 25 November pull request #1722 added -nts tags and -zts aliases for the cli variant. When I checked on 26 November the tags 8.6.0-nts, 8.6.0-zts, 8.6-nts and 8.6-zts existed on Docker Hub, 8.6.0-fpm-nts did not, and 8.6-fpm and 8.6-cli were still thread-safe (output). So there is no php-fpm image without thread safety; if you want one, you build it. The floating tags have already moved: at 20:12 UTC on 26 November php:8-fpm, php:fpm, php:8-cli, php:cli and php:latest were the same images as php:8.6.0-fpm and php:8.6.0-cli, while php:8.5-fpm was still 8.5.13 (digests). If your Dockerfile says one of the first five, the thread-safe build arrives with a plain docker pull.

The 8.6 images also lack mbstring, and laravel/framework requires ext-mbstring. I added it to the 8.6 images with docker-php-ext-install mbstring and changed nothing else.

The discussion in #1719 rests on micro-benchmarks. A docker-library maintainer's php-bench suite, run before 8.6, found the thread-safe build up to 19% slower, and only on 5 of its 21 workloads (mostly recursive Fibonacci). A contributor then ran the suite on an NTS copy of the 8.6 Dockerfile and reported an average slowdown of 1.5%, up to 7% on a CI runner, with the warning that differences under 5% are hard to measure on shared runners. PHP 8.6's own UPGRADING file says "The performance of ZTS builds has been improved". I did not find a framework request or a php-fpm number in that thread (as read on 26 November, saved as the thread). This article is one such number, with the limits listed at the end.

HTTP under php-fpm

Each image ran nginx and php-fpm (8 static workers, OPcache on with timestamp validation off, JIT at its default of off) in one container limited to 4 CPUs, with wrk in a second container: 2 threads, 16 connections, an 8-second warm-up and then 20 seconds per endpoint, every endpoint in a fresh container. The applications were a fresh Laravel 13.44.1 and Symfony 8.1.12 in production mode with warmed caches: Laravel's welcome page and a JSON route returning 50 users from SQLite through Eloquent, and a Symfony Twig page and a JSON route over 50 arrays. Both versions served the same bytes on every endpoint (70,403, 10,251, 3,405 and 3,724 bytes), and none of the 608 measured runs of the second series returned a non-2xx response.

On the server (AMD Ryzen 9 9955HX), eight rounds, medians with the fastest and slowest round (raw rounds):

Endpoint8.5.13, requests/s8.6.0, requests/sChangeRounds 8.6.0 was slower
Laravel page2,603 (2,426–2,626)2,535 (2,472–2,636)−2.6%4 of 8
Laravel JSON887 (880–899)874 (840–891)−1.5%7 of 8
Symfony Twig4,016 (3,975–4,052)3,931 (3,910–3,965)−2.1%8 of 8
Symfony JSON5,338 (5,254–5,362)5,198 (5,166–5,229)−2.6%8 of 8

The median was lower on 8.6 for all four endpoints, and Symfony lost in all 8 rounds. The effect is a couple of percent, and the Laravel page, where the 8.5 rounds span 8%, loses in only 4 of 8. On the MacBook (Apple M1 Pro, Docker Desktop; raw rounds):

Endpoint8.5.13, requests/s8.6.0, requests/sChangeRounds 8.6.0 was slower
Laravel page1,401 (997–1,587)1,435 (904–1,614)+2.4%4 of 8
Laravel JSON361 (330–415)342 (236–396)−5.3%8 of 8
Symfony Twig2,112 (1,616–2,472)1,964 (1,577–2,037)−7.0%7 of 8
Symfony JSON2,735 (2,092–3,077)2,464 (1,683–2,771)−9.9%7 of 8
Bar chart of php-fpm throughput of the 8.6.0 image as a share of the 8.5.13 image, medians of eight rounds, MacBook then server: Laravel page · Mac 102.4%, Laravel page · server 97.4%, Laravel JSON · Mac 94.7%, Laravel JSON · server 98.5%, Symfony Twig · Mac 93.0%, Symfony Twig · server 97.9%, Symfony JSON · Mac 90.1%, Symfony JSON · server 97.4%.
The 8.6.0 image as a share of the 8.5.13 image, php-fpm, 8.5.13 = 100. Teal: the MacBook. Orange: the server. Hover a bar for the raw requests per second and the range of the eight rounds.

The MacBook reports bigger drops on three endpoints, but its 8.5 rounds on the Laravel page range from 1,587 down to 997 requests per second, and the ranges of the two versions overlap on every endpoint. I would not quote a Mac percentage from this. The server's numbers have the opposite property: tight, small, and the same sign on all four endpoints.

Bar chart of how far apart the fastest and the slowest of eight rounds of the same php-fpm 8.5.13 image were, MacBook then server: Laravel page · Mac 59.2%, Laravel page · server 8.2%, Laravel JSON · Mac 25.7%, Laravel JSON · server 2.1%, Symfony Twig · Mac 53.0%, Symfony Twig · server 2.0%, Symfony JSON · Mac 47.1%, Symfony JSON · server 2.1%.
The fastest round over the slowest round of the same image, php-fpm 8.5.13, in percent. Teal: the MacBook. Orange: the server.

That is the difference between the two machines in one picture. The same image moves 2.0 to 8.2% from its slowest round to its fastest on the server and 25.7 to 59.2% on the MacBook, and the effect I am after is a couple of percent.

Would more rounds have rescued the Mac? I asked the rounds I have. Draw n of an image's eight rounds with replacement, do the same for the other image, compare the two medians, repeat 20,000 times, and count how often 8.6 comes out slower. Drag the slider:

Bar chart of the share of bootstrap resamples in which 8.6 came out slower than 8.5, shown for one round per image (a slider goes up to eight), MacBook then server: Laravel page · Mac 45.6%, Laravel page · server 57.3%, Laravel JSON · Mac 76.6%, Laravel JSON · server 88.0%, Symfony Twig · Mac 73.3%, Symfony Twig · server 100.0%, Symfony JSON · Mac 77.7%, Symfony JSON · server 100.0%.
Share of resamples in which the 8.6 median was below the 8.5 median, for 1 to 8 rounds per image. Teal: the MacBook. Orange: the server.

On the server a single round already says "8.6 is slower" on both Symfony routes in 100% of resamples, and the Laravel page, where the server's own rounds are most spread out, climbs from 57% at one round to 88% at eight. On the MacBook three endpoints reach 89 to 96% at eight rounds, so the sign is probably right there too; the Laravel page ends at 34%, which means that in about two thirds of resamples 8.6 comes out faster. More rounds help the sign. They do not tell the MacBook how big the effect is, because the spread stays; only a quieter machine does that. A bootstrap of eight rounds says what those eight rounds support, not what is true.

Latency tells the same story, with one trap. On the server the median latency rose 1.4 to 3.3% on 8.6, in step with the throughput. The 99th percentile did not move at all: 53.5 to 62.7 ms on every endpoint and both versions, within 0.1 ms of each other, although the medians range from 1.6 to 9.3 ms. A flat p99 that ignores the endpoint is not PHP. I read it as the container's CPU quota: a 4-CPU limit is enforced in 100 ms periods, and the CPU counters of the diagnosis run below show every period throttled (120 throttled periods in 12 seconds), so a saturated container makes some requests wait out the rest of a period. Under saturation with a CPU limit, p99 measures the limit.

The version or the build

To split the gap into "version" and "build" I need 8.5 built like the 8.6 image and 8.6 built like the 8.5 one. The official php:8.5.13-zts and php:8.6.0-nts images are exactly that, but neither has php-fpm, so I used the thing they do have: php-cgi, which speaks the same FastCGI protocol, with the same eight forked worker processes behind the same nginx, in all four images (8.5 NTS and ZTS, 8.6 NTS and ZTS), five rounds, a fresh container per endpoint (server rounds, MacBook rounds). The configure flags of 8.6.0-nts and 8.6.0-cli differ only by --enable-zts, --disable-zend-signals and --enable-embed.

Endpoint, requests/s8.5 NTS8.5 ZTS8.6 NTS8.6 ZTSThread safety on 8.5Thread safety on 8.68.6 vs 8.5, NTS
Laravel page2,4892,4122,5282,472−3.1%−2.2%+1.6%
Laravel JSON914891929912−2.4%−1.9%+1.7%
Symfony Twig4,6004,3614,6834,474−5.2%−4.5%+1.8%
Symfony JSON6,2926,0336,3916,096−4.1%−4.6%+1.6%
Bar chart of php-cgi throughput as a share of the usual 8.5.13 build, medians of five rounds, for 8.5 thread-safe, 8.6 without thread safety and 8.6 thread-safe, shown for the server (a selector switches to the MacBook): Laravel page · 8.5 ZTS 96.9%, Laravel page · 8.6 NTS 101.6%, Laravel page · 8.6 ZTS 99.3%, Laravel JSON · 8.5 ZTS 97.6%, Laravel JSON · 8.6 NTS 101.7%, Laravel JSON · 8.6 ZTS 99.8%, Symfony Twig · 8.5 ZTS 94.8%, Symfony Twig · 8.6 NTS 101.8%, Symfony Twig · 8.6 ZTS 97.2%, Symfony JSON · 8.5 ZTS 95.9%, Symfony JSON · 8.6 NTS 101.6%, Symfony JSON · 8.6 ZTS 96.9%.
php-cgi: three builds as a share of the usual 8.5.13 (NTS = 100). Teal: 8.5 thread-safe. Orange: 8.6 without thread safety. Purple: 8.6 thread-safe. The Machine selector switches to the MacBook.

Two things stand out, and both hold on all four endpoints. Thread safety costs 2.4 to 5.2% on 8.5 and 1.9 to 4.6% on 8.6. And with thread safety held constant, 8.6 is 1.0 to 2.6% faster than 8.5 on the thread-safe builds and 1.6 to 1.8% faster on the plain ones. So the arithmetic of the php-fpm table is: a small gain from the version, a larger loss from the build, and a small net loss. UPGRADING's sentence about ZTS performance fits that: 8.6 ZTS is a little faster than 8.5 ZTS, it just is not as fast as NTS.

Two checks on that control. The thread-safety cost is not an average of noisy rounds: on the server the thread-safe build was slower than the plain one in all 5 of 5 rounds on every endpoint, for both versions, and 8.6 plain was faster than 8.5 plain in 4 to 5 of 5. And does php-cgi stand in for php-fpm? The one comparison both series contain is 8.5 NTS against 8.6 ZTS, the pair of images people actually swap: php-cgi says 0.2 to 3.1% slower, php-fpm said 1.5 to 2.6% slower on the same four endpoints, so the stand-in is good to about 1.9 percentage points. It is a stand-in, not the same program: php-cgi forks its eight children once and never recycles them (PHP_FCGI_MAX_REQUESTS=0) and has no process manager, so the direction and the rough size transfer to php-fpm, not the last decimal.

The MacBook, run the same way, agrees on the sign of the thread-safety cost for both Laravel endpoints and not for Symfony, and it puts 8.6 NTS ahead of 8.5 NTS by far more than the server does. With spreads of tens of percent I read that as noise:

Endpoint, requests/s8.5 NTS8.5 ZTS8.6 NTS8.6 ZTSThread safety on 8.5Thread safety on 8.68.6 vs 8.5, NTS
Laravel page2,1131,9712,2261,987−6.7%−10.7%+5.4%
Laravel JSON520502580480−3.3%−17.1%+11.6%
Symfony Twig2,8362,9223,2722,971+3.1%−9.2%+15.4%
Symfony JSON4,0914,1664,2294,283+1.8%+1.3%+3.4%

As a third look I ran each build on PHP's built-in server (php -S: one PHP process per application and one connection, -t1 -c1), which has no web server and no worker pool (server rounds, MacBook rounds). On the server the thread-safe build was 2.0 to 3.4% slower than the plain one on 8.5, and the two plain builds were within 0.9% of each other. It says the same thing as php-cgi.

Where the cost comes from

I measured what a request costs, not why. For Symfony's JSON route on the two php-cgi images (8.6.0 NTS against 8.6.0 ZTS), three pairs of runs, a cgroup's CPU counters divided by the number of requests (cpu-split.txt):

Symfony JSON, php-cgiRequests/sUser CPU per requestSystem CPU per requestTotal per request
8.6.0 NTS6,325452 µs185 µs637 µs
8.6.0 ZTS6,077484 µs176 µs661 µs

The thread-safe worker uses 7.1% more user CPU per request and no more system CPU, which makes the total 661 against 637 microseconds, 3.8% more, so the extra work is in PHP, not in the kernel. A strace of one worker (NTS, ZTS) shows 233 system calls per request on NTS and 231 on ZTS, so it is not more syscalls either. What does differ is the timer behind max_execution_time: the NTS build calls setitimer twice per request, the ZTS build calls timer_create, timer_settime twice and timer_delete. A tight loop of set_time_limit() (timer-test.txt) costs 150 ns per call on NTS and 240 ns on ZTS, about 90 ns more; even a handful of those per request come to well under a microsecond, against a gap of 24 microseconds. I think the rest is the thread-local access to the interpreter's globals that ZTS needs everywhere and NTS does not, but I did not isolate it.

The timer is also a behaviour change, not only a cost. A commenter on #1719 points out that on Linux the thread-safe build enables PHP's execution timers, so max_execution_time and set_time_limit() now measure wall-clock time (CLOCK_BOOTTIME) instead of CPU time: time spent waiting on a database or an HTTP call now counts toward the limit. I reproduced the effect on the official images (first item of the section below); the clock the build uses is the commenter's claim, which I did not check. A script that waits on I/O close to its limit can start timing out after a plain docker pull, with no change in its code.

Threads: FrankenPHP and memory

Thread safety is not free, and what you buy with it is threads. So I also ran the same two applications on FrankenPHP 1.14 (Caddy with PHP embedded, 8 PHP threads, classic mode: no worker script, so every request bootstraps the framework just like under php-fpm) on PHP 8.5.13 and 8.6.0, with the same four endpoints, the same 4-CPU limit and five rounds (server rounds, MacBook rounds). Requests per second on the server, medians:

Endpoint, requests/sphp-fpm 8.5php-fpm 8.6FrankenPHP 8.5FrankenPHP 8.6FrankenPHP vs php-fpm, 8.5FrankenPHP vs php-fpm, 8.6
Laravel page2,5292,4572,8422,945+12.4%+19.9%
Laravel JSON886881825842−6.9%−4.4%
Symfony Twig4,0013,9214,5014,606+12.5%+17.5%
Symfony JSON5,3455,1846,2256,393+16.5%+23.3%

FrankenPHP 8.6 and 8.5 are within 3.6% of each other on every endpoint. Against php-fpm on the same PHP version, FrankenPHP is 12.4 to 23.3% faster on three endpoints and 4.4 to 6.9% slower on the Laravel JSON route. On the MacBook FrankenPHP is ahead of php-fpm on all four endpoints, by 11.2 to 33.5%, though I read the Mac numbers with the caution from above. Neither says anything about worker mode, which exists to skip the bootstrap and is the real reason to use FrankenPHP; I did not measure it.

Bar chart of requests per second for php-fpm 8.5, php-fpm 8.6, FrankenPHP 8.5 and FrankenPHP 8.6, shown for the Laravel page on the server (selectors switch machine and endpoint): php-fpm 8.5 (NTS) 2,529.0, php-fpm 8.6 (ZTS) 2,457.0, FrankenPHP 8.5 2,842.0, FrankenPHP 8.6 2,945.0.
Pick a machine and an endpoint. The bars are medians of five rounds; the tooltip has each runtime's range and the memory it held after the load.

Memory I read from the container's cgroup after each endpoint's load, as anonymous memory (every process's own) plus shared memory (OPcache's), without the page cache, medians of five rounds (readings), in MiB:

MiB held after the loadServer, Laravel pageServer, Symfony TwigMacBook, Laravel pageMacBook, Symfony Twig
php-fpm 8.5.13 (NTS)45284732
php-fpm 8.6.0 (ZTS)46295034
FrankenPHP 8.5.13 (ZTS)58447061
FrankenPHP 8.6.0 (ZTS)59447658

The thread-safe php-fpm image holds 3 to 7% more than the NTS one, and FrankenPHP in classic mode holds 27 to 91% more than php-fpm on the same PHP version. Eight threads in one process did not save memory over eight processes here; I did not look into why.

CLI and JIT

On the command line there is no web server and nothing to take turns: each workload ran in a fresh container, five rounds per image, with the images rotating through the first position. PHPStan analysed three directories of Laravel's own source at level 5, Composer rebuilt Laravel's authoritative classmap, Symfony cleared its production cache, and Laravel ran artisan list ten times. On the server, in milliseconds, with the fastest and slowest of the five rounds (rounds, checksums):

Workload, ms8.5.13 NTS8.5.13 ZTS8.6.0 NTS8.6.0 ZTS
PHPStan, level 52,704 (2,697–2,705)2,715 (2,714–2,819)2,695 (2,597–2,703)2,709 (2,703–2,710)
Composer dump-autoload627 (622–631)650 (646–655)628 (625–639)623 (620–635)
Symfony cache:clear103 (100–103)110 (107–111)102 (100–106)107 (104–108)
10 × artisan list648 (620–661)656 (640–667)659 (626–681)635 (630–639)

The medians of the four images differ by at most 7.8% in a row, and the five rounds of one image span 2 to 9%. For the interpreter itself I wrote seven CPU-bound cases (n-body, fannkuch, Mandelbrot, binary trees, sorting objects, strings and regular expressions, JSON and array functions), each printing a checksum so that a wrong result could not hide behind a fast time. All 14 checksums, with and without the JIT, were identical on every image in every round on both machines.

Case, ms8.5.13 NTS8.5.13 ZTS8.6.0 NTS8.6.0 ZTSTime, 8.6 vs 8.5 ZTS (+ is slower)Same, with JIT
n-body409.2409.3410.7416.4+1.7%+0.8%
fannkuch (9)98.3105.0102.199.8−5.0%+0.4%
Mandelbrot38.438.638.238.2−1.0%+0.0%
binary trees (depth 15)65.868.766.066.8−2.8%+0.4%
sorting 300,000 objects885.5920.3890.8905.2−1.6%−2.3%
strings and regex28.929.429.229.3−0.3%−0.4%
JSON and array functions334.6335.5324.9324.7−3.2%−3.4%

Without the JIT, 8.6 NTS was within 3.9% of 8.5 NTS and 8.6 ZTS within 5.0% of 8.5 ZTS on every case. With the tracing JIT (opcache.jit=tracing, 64 MB buffer) the largest difference from 8.5 on the same build was 3.4%. The thread-safe build cost between 0.0 and 6.8% on the CPU-bound cases, in line with the micro-benchmarks in #1719. In these runs none of the release's optimisations showed up in a framework request or a tool run. I would not choose between 8.5 and 8.6 on speed.

One consequence reaches my own earlier article. Its function-level benchmark compared php:8.5.11-cli with php:8.6.0RC3-cli, and the second image is thread-safe while the first is not (PHP_ZTS printed 1 for 8.6.0RC3 and nothing for 8.5.11 when I checked on 26 November, output). So the rows there that came out slower on 8.6 carry some of the cost measured above, between 0 and 6.8% on the CPU-bound cases, and a rerun on php:8.6.0-nts would show how much; I have not done that rerun.

Things I did not expect

Five things that came up while I was looking for the main result, each with its evidence file in the work directory.

1. A one-line script that tells the two builds apart. A one-second limit and a two-second sleep, which uses no CPU at all (output, script):

php -r 'set_time_limit(1); usleep(2000000); echo "survived\n";'
ImageFirst line of php -vset_time_limit(1), then a 2 s sleep
php:8.5.13-cliPHP 8.5.13 (cli) (built: Nov 24 2026 04:21:10) (NTS)survived a 2.0 s sleep
php:8.5.13-ztsPHP 8.5.13 (cli) (built: Nov 24 2026 04:23:11) (ZTS)fatal error: maximum execution time of 1 second exceeded
php:8.6.0-ntsPHP 8.6.0 (cli) (built: Nov 26 2026 01:30:59) (NTS)survived a 2.0 s sleep
php:8.6.0-cliPHP 8.6.0 (cli) (built: Nov 24 2026 04:20:24) (ZTS)fatal error: maximum execution time of 1 second exceeded

The build decides, not the version: 8.5.13 ZTS fails too, and the last parentheses of php -v say which one you have. This is the wall-clock limit from the section above caught in the act. If you have jobs that wait on I/O close to their max_execution_time, this is the test to run before moving to a thread-safe image.

2. Three quarters of a Symfony request's system calls are file-existence probes. The strace of the JSON route counted 173.9 access() calls per request on the x86_64 server for NTS and 174.1 for ZTS, which is 74.7% and 75.3% of all system calls, and 173.6 faccessat() calls per request on the arm64 MacBook (that architecture has no access()). The paths are Symfony's vendor files, reached through vendor/composer/../symfony/. My first guess was Composer's autoloader, so I generated an authoritative class map inside the container: 173.5 calls per request before, 173.7 after. The evidence is in faccessat-test.txt and the two strace files above. I do not know where they come from, nor what they cost; with OPcache's timestamp checks off I did not expect any.

3. The cheapest speedup in this article was a line in a .env file. Moving Laravel's sessions from files to memory took the welcome page (numbers in session-trap.txt) from 1,224 requests per second in its first window to 2,055, 68% more on the same build, and removed the decay entirely.

4. A thread-safe PHP cannot load an extension built for the other. I took sodium.so out of php:8.6.0-nts and loaded it into php:8.6.0-cli, then the other way round; same version, same release, only the thread safety differs (output, script):

NTS sodium.so in the ZTS image: undefined symbol: compiler_globals
ZTS sodium.so in the NTS image: Module compiled with build ID=API20261112,TS
                                PHP    compiled with build ID=API20261112,NTS
                                These options need to match

Extensions you build inside the image (docker-php-ext-install, PECL, PIE) are compiled for whatever PHP the image has and are fine. A prebuilt binary you copy in is not, unless its vendor ships a thread-safe build. The #1719 thread names APM agents, profilers and loaders as the practical casualties; I tested only sodium.

5. The thread-safe tags are aliases. php:8.6.0-zts and php:8.6-zts have exactly the digest of php:8.6.0-cli (sha256:9bc69093cdff…, all digests): there is no separate thread-safe image, the default one is it. php:8.6.0-nts is a different image, and it was built on 26 November 2026, two days after the default one (24 November 2026), as the first line of php -v shows.

The series I threw away

My first two series said something much more dramatic, and I almost published it. On the MacBook the 8.6 php-fpm image was 11.7 to 27.4% slower on the two Symfony routes, and on the server it was 68.7 to 70.2% slower on both, in 8 of 8 rounds; php-cgi reproduced that on the two thread-safe builds and not on the two others. It looked like a clear, reproducible, build-dependent result, on two architectures.

It was my harness. The Laravel app had SESSION_DRIVER=file, so every request to a web route wrote a session file: 23,034 files after one 20-second window. Laravel's own throughput fell as they piled up (on the plain 8.6 build 1,224, 719, 547, 451 and 396 requests per second over five consecutive 20-second windows), and the Symfony endpoints, which I measured after Laravel in the same container, collapsed on the thread-safe build: 800 and 1,185 requests per second after Laravel's traffic against 2,649 and 3,677 for the same image with Symfony alone, while the plain build stayed above 4,300. I do not know why only the thread-safe build collapsed. After I moved sessions to memory and gave every endpoint a fresh container, the big drop disappeared on both machines and Laravel got faster (2,055 requests per second on a plain build, against 1,224 in the first window before). Everything above is from the second series; the raw files of the first are in the repository (MacBook, first session, MacBook, second session, server, server php-cgi).

Line chart of the Laravel welcome page's requests per second over five consecutive 20-second windows with file sessions, falling for both builds: 8.6.0 NTS 1,224, 719, 547, 451, 396; 8.6.0 ZTS 1,104, 631, 458, 374, 293.
Laravel's welcome page in five consecutive 20-second windows with file sessions, one fresh php-cgi container per build, MacBook. Teal: ZTS. Orange: NTS.

The lesson is the one I should have drawn from the first php-fpm series, which made Symfony look 65% slower while sixteen other containers were running, and which I put down to those containers and now think was the same artifact: a result that is large, reproducible and confined to one variable is exactly the kind that deserves a second harness. The sign of the effect (thread-safe slower) was right all along. Only the size was wrong, by a factor of about thirty.

What else is different in the 8.6 image

  • No mbstring. Fine for a plain script; Laravel requires it, so it has to be added.
  • Zend signals are disabled (--disable-zend-signals), as in the 8.5 ZTS image. The control above includes that flag in the cost of "thread-safe", because the two official 8.6 variants differ in it.
  • --with-pic became --enable-pic in the 8.6 sources, so a configure line copied from an 8.5 build stops with "The Libtool --with-pic/--without-pic configure option is obsolete" when you compile 8.6 yourself.
  • PHPStan reports a different number of errors on the same code. It found 3,256 on 8.5 and 3,218 on 8.6 for the same three Laravel directories. The difference is SortDirection, a new built-in enum in 8.6 that Laravel's Collection::sortBy() already uses: on 8.5 the class is unknown (39 errors mention it), while on 8.6 it exists and 1 still mentions it. If you gate CI on a PHPStan baseline, expect it to shift when you change the PHP version of the job.

What a few percent means for a fleet

Throughput is continuous, but you buy containers in whole numbers, so a 2% loss costs nothing at most loads and a whole container at some. The chart is arithmetic on the server's medians: peak load divided by (measured requests per second times the utilisation you are willing to run at), rounded up. It is not a forecast for your application. Slide to find the loads where php-fpm 8.5 and 8.6 part ways.

Bar chart of how many 4-CPU containers a peak load needs for php-fpm 8.5, php-fpm 8.6 and FrankenPHP 8.6, shown for the default scenario (a slider and two selectors change load, endpoint and target utilisation): php-fpm 8.5 (NTS) 1.0, php-fpm 8.6 (ZTS) 2.0, FrankenPHP 8.6 (ZTS) 1.0.
Containers of 4 CPUs needed for a peak load, from the server's medians for php-fpm 8.5, php-fpm 8.6 and FrankenPHP 8.6. Teal: php-fpm 8.5. Orange: php-fpm 8.6. Gold: FrankenPHP 8.6.

On Symfony Twig at 3,000 requests per second and 75% target utilisation, php-fpm 8.5 needs 1 container and php-fpm 8.6 needs 2. At the 75% setting the thread-safe php-fpm image needs one container more than 8.5 in 9 of the 52 combinations of load and endpoint, and the same number in the other 43. FrankenPHP in classic mode needs the same number of containers as php-fpm 8.5 or fewer on three endpoints and the same or more on the Laravel JSON route, where it lost throughput; it also held 27 to 91% more memory in the earlier section, and a container count is not a memory budget.

What to do with this

  • Check the thread safety before you compare anything: php -r 'var_dump(PHP_ZTS);', or read the last parentheses of the first line of php -v. If two images differ there, you are benchmarking the build, whatever the tags say.
  • Expect a few percent, not a cliff. On a quiet server a Laravel or Symfony request on php-fpm cost 1.5 to 2.6% in throughput here. If your fleet is sized with a 10% margin you will not notice; if it is sized to the edge, measure your own application first.
  • If you want 8.6 without the thread-safe overhead, use php:8.6-nts for the command line (or build php-fpm yourself without --enable-zts: there is no official NTS php-fpm image, and I did not build one).
  • Pin the minor version. php:8.5-fpm stays on 8.5 and NTS; php:8-fpm, php:fpm and php:latest have already moved to a thread-safe 8.6, so a rebuild changes the build type without anyone editing the Dockerfile.
  • Judge a canary by CPU per request, not by throughput. Throughput of a saturated container and its p99 are bent by the CPU quota (above); CPU seconds per request is the number that moved here (7.1% more user CPU, 3.8% more in total) and it does not depend on how saturated the container is.
  • Check prebuilt extensions. Any binary you copy into the image needs a thread-safe build; anything compiled in the image is fine.
  • Check your time limits. On the thread-safe build max_execution_time counts wall-clock time, not CPU time.
  • Upgrade for the features, not for speed. CPU-bound code and tools ran the same on 8.5 and 8.6.
  • Be suspicious of your own big numbers. My first one was about thirty times too large and reproducible on two machines.

Reproduce it

Everything I ran is below, copied from the files as they were when I ran them, and the same files, with the raw runs of every series and a README that maps each claim of this article to a file, are in the repository. Clone it, or put the scripts in one directory, with apps/ (the two applications), docker/ (the images), cli/ (the CLI workloads) and an empty runs/ next to them. ./build.sh followed by ./http-bench.sh is the whole php-fpm series; the other series are below, and chain.sh runs them one after another. You need Docker, and for the results the numbers in this article come from, a machine that is otherwise quiet.

The two applications

Laravel 13.44.1 (a fresh laravel/laravel project) on SQLite, with seven settings changed from the skeleton's .env.example: APP_ENV=production, APP_DEBUG=false, LOG_STACK=stderr, LOG_LEVEL=error, SESSION_DRIVER=array (file sessions are the trap described above), QUEUE_CONNECTION=sync and CACHE_STORE=file; the file is .env.benchmark in the repository, with the application key left blank. SQLite needs no extra step: pdo_sqlite and sqlite3 are compiled into every official image I used (php -m lists both), which is why the php-fpm and php-cgi Dockerfiles below do not install them. The users table holds 200 rows; one way to get them is php artisan migrate --force and then User::factory(200)->create() in tinker. I tried that on a throwaway copy (output): 200 rows, and 50 of them encode to a JSON of the size quoted above, give or take a few bytes, because the factory's data is random. The two routes:

<?php use App\Models\User; use Illuminate\Support\Facades\Route; Route::get('/', function () { return view('welcome'); }); Route::get('/api/users', function () { return User::query()->orderBy('id')->limit(50)->get(); });

Symfony 8.1.12 with Twig 3.31.1; its composer.json requires:

"require": { "php": ">=8.4", "ext-ctype": "*", "ext-iconv": "*", "phpstan/phpstan": "^2.3", "symfony/console": "8.1.*", "symfony/dotenv": "8.1.*", "symfony/flex": "^2", "symfony/framework-bundle": "8.1.*", "symfony/maker-bundle": "^1.68", "symfony/runtime": "8.1.*", "symfony/twig-bundle": "8.1.*", "symfony/yaml": "8.1.*", "twig/extra-bundle": "^2.12|^3.0", "twig/twig": "^2.12|^3.0" },

One controller with two routes, and the template of the first:

<?php declare(strict_types=1); namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; final class BenchController extends AbstractController { /** @return list<array{id: int, name: string, email: string, tags: list<string>}> */ private function items(): array { $items = []; for ($i = 1; $i <= 50; ++$i) { $items[] = [ 'id' => $i, 'name' => 'Item ' . $i, 'email' => 'item' . $i . '@example.com', 'tags' => ['a' . $i % 3, 'b' . $i % 5], ]; } return $items; } #[Route('/', name: 'home')] public function home(): Response { return $this->render('bench/home.html.twig', ['items' => $this->items()]); } #[Route('/api/items', name: 'items')] public function items_json(): JsonResponse { return $this->json($this->items()); } }
{% extends 'base.html.twig' %} {% block title %}Items{% endblock %} {% block body %} <h1>Items</h1> <ul> {% for item in items %} <li>#{{ item.id }} {{ item.name|upper }} &lt;{{ item.email }}&gt; {{ item.tags|join(', ') }}</li> {% endfor %} </ul> {% endblock %}

and its layout, base.html.twig:

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>{% block title %}Welcome!{% endblock %}</title> <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>"> {% block stylesheets %} {% endblock %} {% block javascripts %} {% endblock %} {% set frankenphp_hot_reload = app.request.server.get('FRANKENPHP_HOT_RELOAD') %} {% if frankenphp_hot_reload %} <meta name="frankenphp-hot-reload:url" content="{{ frankenphp_hot_reload }}"> <script src="https://cdn.jsdelivr.net/npm/idiomorph"></script> <script src="https://cdn.jsdelivr.net/npm/frankenphp-hot-reload/+esm" type="module"></script> {% endif %} </head> <body> {% block body %}{% endblock %} </body> </html>

The php-fpm image

One image per PHP version, built from the official php-fpm image: the only thing that changes between two runs is BASE.

# One image per PHP version: nginx + php-fpm + both apps, so the only thing # that changes between runs is BASE. ARG BASE FROM ${BASE} RUN apt-get update && apt-get install -y --no-install-recommends nginx libonig-dev \ && rm -rf /var/lib/apt/lists/* \ && (php -m | grep -qx mbstring || docker-php-ext-install -j"$(nproc)" mbstring) COPY apps/laravel /var/www/laravel COPY apps/symfony /var/www/symfony COPY docker/http/nginx.conf /etc/nginx/nginx.conf COPY docker/http/php-fpm.conf /usr/local/etc/php-fpm.d/zz-bench.conf COPY docker/http/opcache.ini /usr/local/etc/php/conf.d/zz-opcache.ini COPY docker/http/start.sh /start.sh RUN chown -R www-data:www-data /var/www/laravel/storage /var/www/laravel/bootstrap/cache /var/www/laravel/database /var/www/symfony/var \ && cd /var/www/laravel && php artisan config:cache && php artisan route:cache && php artisan view:cache \ && cd /var/www/symfony && php bin/console cache:clear --env=prod && php bin/console cache:warmup --env=prod \ && chown -R www-data:www-data /var/www/symfony/var /var/www/laravel/storage /var/www/laravel/bootstrap/cache EXPOSE 8080 8081 CMD ["/start.sh"]
user www-data; worker_processes 2; pid /tmp/nginx.pid; events { worker_connections 1024; } http { access_log off; error_log /dev/stderr warn; include /etc/nginx/mime.types; server { listen 8080; root /var/www/laravel/public; index index.php; location / { try_files $uri /index.php?$query_string; } location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/tmp/fpm.sock; } } server { listen 8081; root /var/www/symfony/public; location / { try_files $uri /index.php$is_args$args; } location ~ ^/index\.php(/|$) { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/index.php; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_pass unix:/tmp/fpm.sock; } } }
[www] listen = /tmp/fpm.sock listen.owner = www-data listen.group = www-data pm = static pm.max_children = 8 clear_env = no catch_workers_output = yes
opcache.enable=1 opcache.validate_timestamps=0 opcache.memory_consumption=128 opcache.max_accelerated_files=20000
#!/bin/sh php-fpm -D exec nginx -g 'daemon off;'

Building every image the series need, including wrk, which is built from source in its own image:

#!/usr/bin/env bash # Builds every image the series use from the official php and FrankenPHP images (one image per build: the only thing # that differs between two runs is the BASE image), plus wrk. Run on each machine before the series. set -euo pipefail cd "$(dirname "$0")" for v in 8.5.13 8.6.0; do docker build -q --build-arg BASE=php:$v-fpm -t bench-http:$v -f docker/http/Dockerfile .; done for v in 8.5.13-cli 8.5.13-zts 8.6.0-nts 8.6.0-cli; do docker build -q --build-arg BASE=php:$v -t bench-cgi:$v -f docker/cgi/Dockerfile . docker build -q --build-arg BASE=php:$v -t bench-cli:$v -f docker/Dockerfile.cli . done for v in 8.5 8.6; do docker build -q --build-arg BASE=dunglas/frankenphp:1.14-php$v-trixie -t bench-fk:$v -f docker/frankenphp/Dockerfile .; done docker image inspect wrk-native >/dev/null 2>&1 || docker build -q -t wrk-native -f docker/Dockerfile.wrk docker
FROM debian:trixie-slim AS build RUN apt-get update && apt-get install -y --no-install-recommends build-essential git ca-certificates libssl-dev unzip perl \ && git clone --depth 1 https://github.com/wg/wrk /wrk && make -C /wrk -j4 FROM debian:trixie-slim RUN apt-get update && apt-get install -y --no-install-recommends libssl3 && rm -rf /var/lib/apt/lists/* COPY --from=build /wrk/wrk /usr/local/bin/wrk ENTRYPOINT ["wrk"]

The measuring loop

Every endpoint gets a fresh container, a warm-up and a measured window, and the two images swap the order in every round:

#!/usr/bin/env bash # HTTP: nginx + php-fpm (static 8 workers, OPcache on, no timestamp validation) in one container # limited to 4 CPUs, wrk in another container (2 threads, 16 connections, 20 s per endpoint). # Every endpoint gets a fresh container, so what one endpoint leaves behind (files, cache, memory) cannot reach the next. # The two versions alternate (A B B A A B ...) so slow drift does not favour one of them. set -euo pipefail cd "$(dirname "$0")" ROUNDS=${ROUNDS:-5}; DUR=${DUR:-20}; WARM=${WARM:-8} OUT=runs/http-$(date +%Y%m%d-%H%M%S).tsv printf 'round\tversion\tendpoint\trps\tp50_ms\tp99_ms\tnon2xx\n' > "$OUT" docker network create benchnet >/dev/null 2>&1 || true ENDPOINTS=("laravel-welcome:8080/" "laravel-json:8080/api/users" "symfony-twig:8081/" "symfony-json:8081/api/items") ms() { awk -v v="$1" 'BEGIN{ if (v ~ /us$/) {sub(/us/,"",v); printf "%.3f", v/1000} else if (v ~ /ms$/) {sub(/ms/,"",v); printf "%.3f", v} else if (v ~ /s$/) {sub(/s/,"",v); printf "%.3f", v*1000} }'; } run_version() { local round=$1 v=$2 for e in "${ENDPOINTS[@]}"; do name=${e%%:*}; url=${e#*:} docker rm -f srv >/dev/null 2>&1 || true docker run -d --name srv --network benchnet --cpus 4 "bench-http:$v" >/dev/null sleep 3 docker run --rm --network benchnet --cpus 2 wrk-native -t2 -c16 -d${WARM}s "http://srv:$url" >/dev/null res=$(docker run --rm --network benchnet --cpus 2 wrk-native -t2 -c16 -d${DUR}s --latency "http://srv:$url") rps=$(echo "$res" | awk '/Requests\/sec/{print $2}') p50=$(ms "$(echo "$res" | awk '$1=="50%"{print $2}')") p99=$(ms "$(echo "$res" | awk '$1=="99%"{print $2}')") bad=$(echo "$res" | awk '/Non-2xx/{print $NF}'); bad=${bad:-0} printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$round" "$v" "$name" "$rps" "$p50" "$p99" "$bad" | tee -a "$OUT" docker rm -f srv >/dev/null done } for r in $(seq 1 "$ROUNDS"); do if (( r % 2 )); then order=(8.5.13 8.6.0); else order=(8.6.0 8.5.13); fi for v in "${order[@]}"; do run_version "$r" "$v"; done done echo "written $OUT"

The other runtimes

The php-cgi image is the Dockerfile above with the php-fpm configuration line removed and /start.sh replaced by this script; BASE is one of the four CLI images:

#!/bin/sh # FastCGI through php-cgi (8 forked children, like the 8 static php-fpm workers), so that the same multi-process # request path can be measured on every official image, including the ones that have no php-fpm (php:*-nts, php:8.5.13-zts). umask 000 rm -f /tmp/fpm.sock su -s /bin/sh www-data -c "PHP_FCGI_CHILDREN=8 PHP_FCGI_MAX_REQUESTS=0 exec php-cgi -d cgi.force_redirect=0 -b /tmp/fpm.sock" & for i in 1 2 3 4 5 6 7 8 9 10; do [ -S /tmp/fpm.sock ] && break; sleep 0.5; done exec nginx -g 'daemon off;'

FrankenPHP is a separate Dockerfile and a Caddyfile, with the same applications and the same OPcache settings:

# FrankenPHP (a threaded SAPI: one process, PHP threads inside it) serving the same two apps as the php-fpm images, # in classic mode (no worker script: every request bootstraps the framework, like under php-fpm). ARG BASE FROM ${BASE} RUN install-php-extensions mbstring pdo_sqlite >/dev/null COPY apps/laravel /var/www/laravel COPY apps/symfony /var/www/symfony COPY docker/frankenphp/Caddyfile /etc/frankenphp/Caddyfile COPY docker/http/opcache.ini /usr/local/etc/php/conf.d/zz-opcache.ini RUN cd /var/www/laravel && php artisan config:cache && php artisan route:cache && php artisan view:cache \ && cd /var/www/symfony && php bin/console cache:clear --env=prod && php bin/console cache:warmup --env=prod EXPOSE 8080 8081
{ admin off auto_https off frankenphp { num_threads 8 max_threads 8 } } :8080 { root * /var/www/laravel/public php_server } :8081 { root * /var/www/symfony/public php_server }

The php-cgi series, the same loop over the four builds (note the rotation of the first position):

#!/usr/bin/env bash # Multi-process control: the same nginx + 8 FastCGI processes as http-bench.sh, but served by php-cgi (8 forked # children), which exists in every official CLI image, including php:8.6.0-nts and php:8.5.13-zts that have no php-fpm. # Every endpoint gets a fresh container, so what one endpoint leaves behind (files, cache, memory) cannot reach the next. # Four builds take turns going first (rotating), so slow drift does not favour one of them. set -euo pipefail cd "$(dirname "$0")" ROUNDS=${ROUNDS:-5}; DUR=${DUR:-20}; WARM=${WARM:-8} OUT=runs/cgi-$(date +%Y%m%d-%H%M%S).tsv printf 'round\tversion\tendpoint\trps\tp50_ms\tp99_ms\tnon2xx\n' > "$OUT" docker network create benchnet >/dev/null 2>&1 || true BUILDS=(8.5.13-cli 8.5.13-zts 8.6.0-nts 8.6.0-cli) ENDPOINTS=("laravel-welcome:8080/" "laravel-json:8080/api/users" "symfony-twig:8081/" "symfony-json:8081/api/items") ms() { awk -v v="$1" 'BEGIN{ if (v ~ /us$/) {sub(/us/,"",v); printf "%.3f", v/1000} else if (v ~ /ms$/) {sub(/ms/,"",v); printf "%.3f", v} else if (v ~ /s$/) {sub(/s/,"",v); printf "%.3f", v*1000} }'; } run_version() { local round=$1 v=$2 for e in "${ENDPOINTS[@]}"; do name=${e%%:*}; url=${e#*:} docker rm -f srv >/dev/null 2>&1 || true docker run -d --name srv --network benchnet --cpus 4 "bench-cgi:$v" >/dev/null sleep 3 docker run --rm --network benchnet --cpus 2 wrk-native -t2 -c16 -d${WARM}s "http://srv:$url" >/dev/null res=$(docker run --rm --network benchnet --cpus 2 wrk-native -t2 -c16 -d${DUR}s --latency "http://srv:$url") rps=$(echo "$res" | awk '/Requests\/sec/{print $2}') p50=$(ms "$(echo "$res" | awk '$1=="50%"{print $2}')") p99=$(ms "$(echo "$res" | awk '$1=="99%"{print $2}')") bad=$(echo "$res" | awk '/Non-2xx/{print $NF}'); bad=${bad:-0} printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$round" "$v" "$name" "$rps" "$p50" "$p99" "$bad" | tee -a "$OUT" docker rm -f srv >/dev/null done } for r in $(seq 1 "$ROUNDS"); do n=${#BUILDS[@]}; k=$(( (r - 1) % n )) for i in $(seq 0 $((n - 1))); do run_version "$r" "${BUILDS[$(( (k + i) % n ))]}"; done done echo "written $OUT"

The thread series: four contenders (the two php-fpm images and the two FrankenPHP ones, rotating), and memory read from the container's cgroup after each endpoint's load:

#!/usr/bin/env bash # Threads against processes, same apps, same limits (4 CPUs, 8 PHP workers or threads, OPcache on, no timestamp # validation, wrk 2 threads / 16 connections / 20 s per endpoint after an 8 s warm-up): # fpm85 php-fpm 8.5.13, NTS, 8 processes (bench-http:8.5.13) # fpm86 php-fpm 8.6.0, ZTS, 8 processes (bench-http:8.6.0) # fk85 FrankenPHP 1.14 on PHP 8.5.13 ZTS, 8 threads, classic mode (bench-fk:8.5) # fk86 FrankenPHP 1.14 on PHP 8.6.0 ZTS, 8 threads, classic mode (bench-fk:8.6) # Every endpoint gets a fresh container; memory is read from the container's cgroup after that endpoint's load: anon (every process's own memory) and shmem (OPcache's # shared memory), without the page cache, so it is the memory the servers themselves hold. # The four contenders take turns going first (rotating), and every page is checked before measuring. set -euo pipefail cd "$(dirname "$0")" ROUNDS=${ROUNDS:-5}; DUR=${DUR:-20}; WARM=${WARM:-8} STAMP=$(date +%Y%m%d-%H%M%S) OUT=runs/threads-$STAMP.tsv; MEM=runs/threads-mem-$STAMP.tsv printf 'round\tcontender\tendpoint\trps\tp50_ms\tp99_ms\tnon2xx\n' > "$OUT" printf 'round\tcontender\tendpoint\tidle_anon\tidle_shmem\tafter_anon\tafter_shmem\tafter_file\tpeak_total\tprocesses\tthreads\n' > "$MEM" docker network create benchnet >/dev/null 2>&1 || true CONTENDERS=("fpm85:bench-http:8.5.13" "fpm86:bench-http:8.6.0" "fk85:bench-fk:8.5" "fk86:bench-fk:8.6") ENDPOINTS=("laravel-welcome:8080/" "laravel-json:8080/api/users" "symfony-twig:8081/" "symfony-json:8081/api/items") ms() { awk -v v="$1" 'BEGIN{ if (v ~ /us$/) {sub(/us/,"",v); printf "%.3f", v/1000} else if (v ~ /ms$/) {sub(/ms/,"",v); printf "%.3f", v} else if (v ~ /s$/) {sub(/s/,"",v); printf "%.3f", v*1000} }'; } cg() { docker exec srv sh -c "grep -E '^$1 ' /sys/fs/cgroup/memory.stat | cut -d' ' -f2"; } run_contender() { local round=$1 label=$2 image=$3 for e in "${ENDPOINTS[@]}"; do name=${e%%:*}; url=${e#*:} docker rm -f srv >/dev/null 2>&1 || true docker run -d --name srv --network benchnet --cpus 4 "$image" >/dev/null sleep 6 local idle_anon idle_shmem idle_anon=$(cg anon); idle_shmem=$(cg shmem) body=$(docker run --rm --network benchnet curlimages/curl -s -w '\n%{http_code}' "http://srv:$url") code=${body##* \n'}; size=${#body} if [[ "$code" != 200 || "$size" -lt 3000 || "$body" == *"<b>Warning</b>"* || "$body" == *"<b>Fatal"* ]]; then echo "BAD RESPONSE $label $name code=$code size=$size" >&2; exit 1 fi docker run --rm --network benchnet --cpus 2 wrk-native -t2 -c16 -d${WARM}s "http://srv:$url" >/dev/null res=$(docker run --rm --network benchnet --cpus 2 wrk-native -t2 -c16 -d${DUR}s --latency "http://srv:$url") rps=$(echo "$res" | awk '/Requests\/sec/{print $2}') p50=$(ms "$(echo "$res" | awk '$1=="50%"{print $2}')") p99=$(ms "$(echo "$res" | awk '$1=="99%"{print $2}')") bad=$(echo "$res" | awk '/Non-2xx/{print $NF}'); bad=${bad:-0} printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$round" "$label" "$name" "$rps" "$p50" "$p99" "$bad" | tee -a "$OUT" local procs threads procs=$(docker exec srv sh -c 'ls /proc | grep -cE "^[0-9]+$"') threads=$(docker exec srv sh -c 'cat /proc/[0-9]*/status 2>/dev/null | awk "/^Threads:/{s+=\$2} END{print s}"') printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$round" "$label" "$name" "$idle_anon" "$idle_shmem" "$(cg anon)" "$(cg shmem)" "$(cg file)" "$(docker exec srv cat /sys/fs/cgroup/memory.peak)" "$procs" "$threads" | tee -a "$MEM" >/dev/null docker rm -f srv >/dev/null done } n=${#CONTENDERS[@]} for r in $(seq 1 "$ROUNDS"); do k=$(( (r - 1) % n )) for i in $(seq 0 $((n - 1))); do c=${CONTENDERS[$(( (k + i) % n ))]}; label=${c%%:*}; image=${c#*:} run_contender "$r" "$label" "$image" done done echo "written $OUT and $MEM"

The php -S series, one process and one connection on the four CLI images:

#!/usr/bin/env bash # Control for HTTP: php -S (one process, one connection, OPcache on, no timestamp validation) # on the four official CLI images. Separates the PHP version from the NTS -> ZTS change, # which php-fpm cannot, because there is no official 8.5 ZTS php-fpm image. set -euo pipefail cd "$(dirname "$0")" ROUNDS=${ROUNDS:-5}; DUR=${DUR:-15}; WARM=${WARM:-5} OUT=runs/builtin-$(date +%Y%m%d-%H%M%S).tsv printf 'round\timage\tendpoint\trps\tp50_ms\tp99_ms\tnon2xx\n' > "$OUT" docker network create benchnet >/dev/null 2>&1 || true IMAGES=(8.5.13-cli 8.5.13-zts 8.6.0-nts 8.6.0-cli) ENDPOINTS=("laravel-welcome:8080/" "laravel-json:8080/api/users" "symfony-twig:8081/" "symfony-json:8081/api/items") ms() { awk -v v="$1" 'BEGIN{ if (v ~ /us$/) {sub(/us/,"",v); printf "%.3f", v/1000} else if (v ~ /ms$/) {sub(/ms/,"",v); printf "%.3f", v} else if (v ~ /s$/) {sub(/s/,"",v); printf "%.3f", v*1000} }'; } OPC="-d opcache.enable_cli=1 -d opcache.validate_timestamps=0 -d opcache.memory_consumption=128 -d opcache.max_accelerated_files=20000 -d memory_limit=512M" run_image() { local round=$1 img=$2 for e in "${ENDPOINTS[@]}"; do name=${e%%:*}; url=${e#*:} docker rm -f srv >/dev/null 2>&1 || true docker run -d --name srv --network benchnet --cpus 2 "bench-cli:$img" sh -c " cd /bench/laravel && php artisan config:cache -q && php artisan route:cache -q && php artisan view:cache -q cd /bench/symfony && php bin/console cache:warmup --env=prod -q cd /bench/laravel && php $OPC -S 0.0.0.0:8080 -t public public/index.php >/dev/null 2>&1 & cd /bench/symfony && exec php $OPC -S 0.0.0.0:8081 -t public public/index.php >/dev/null 2>&1" >/dev/null sleep 8 # the response must be the real page: 200, a plausible size, no PHP warning (wrk alone counts a 200 error page as success) body=$(docker run --rm --network benchnet curlimages/curl -s -w '\n%{http_code}' "http://srv:$url") code=${body##* \n'}; size=${#body} if [[ "$code" != 200 || "$size" -lt 3000 || "$body" == *"<b>Warning</b>"* || "$body" == *"<b>Fatal"* ]]; then echo "BAD RESPONSE $img $name code=$code size=$size" >&2; exit 1 fi docker run --rm --network benchnet --cpus 1 wrk-native -t1 -c1 -d${WARM}s "http://srv:$url" >/dev/null res=$(docker run --rm --network benchnet --cpus 1 wrk-native -t1 -c1 -d${DUR}s --latency "http://srv:$url") rps=$(echo "$res" | awk '/Requests\/sec/{print $2}') p50=$(ms "$(echo "$res" | awk '$1=="50%"{print $2}')") p99=$(ms "$(echo "$res" | awk '$1=="99%"{print $2}')") bad=$(echo "$res" | awk '/Non-2xx/{print $NF}'); bad=${bad:-0} printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$round" "$img" "$name" "$rps" "$p50" "$p99" "$bad" | tee -a "$OUT" done docker rm -f srv >/dev/null } for r in $(seq 1 "$ROUNDS"); do n=${#IMAGES[@]}; k=$(( (r - 1) % n )) for i in $(seq 0 $((n - 1))); do run_image "$r" "${IMAGES[$(( (k + i) % n ))]}"; done done echo "written $OUT"

And the driver that ran the whole second series on each machine:

#!/usr/bin/env bash # The whole second series, one after the other: php-fpm (8 rounds), php-cgi, threads, php -S. Logs next to the results. cd "$(dirname "$0")" ROUNDS=8 ./http-bench.sh > runs/log-http.txt 2>&1; touch runs/CHAIN-DONE-HTTP ./cgi-bench.sh > runs/log-cgi.txt 2>&1; touch runs/CHAIN-DONE-CGI ./thread-bench.sh > runs/log-threads.txt 2>&1; touch runs/CHAIN-DONE-THREADS ./builtin-bench.sh > runs/log-builtin.txt 2>&1; touch runs/CHAIN-DONE-BUILTIN

Diagnosis scripts

CPU per request, split into user and system time, with CPU throttling, from the cgroup of a container under load (start two containers named dg-nts and dg-zts from the two php-cgi images first):

#!/usr/bin/env bash # CPU actually used per request, split into user and system time, plus CFS throttling, read from the container's cgroup # while wrk loads Symfony JSON for 12 s. Containers must already run (names dg-nts, dg-zts, or whatever is passed). # ./cpu-split.sh dg-nts dg-zts for c in "$@"; do s() { docker exec "$c" sh -c "grep -E '^$1 ' /sys/fs/cgroup/cpu.stat | cut -d' ' -f2"; } docker run --rm --network benchnet --cpus 2 wrk-native -t2 -c16 -d4s "http://$c:8081/api/items" >/dev/null u0=$(s user_usec); y0=$(s system_usec); t0=$(s throttled_usec); n0=$(s nr_throttled) out=$(docker run --rm --network benchnet --cpus 2 wrk-native -t2 -c16 -d12s "http://$c:8081/api/items") u1=$(s user_usec); y1=$(s system_usec); t1=$(s throttled_usec); n1=$(s nr_throttled) reqs=$(echo "$out" | awk '/requests in/{print $1}'); rps=$(echo "$out" | awk '/Requests\/sec/{print $2}') awk -v c="$c" -v r="$reqs" -v rps="$rps" -v u=$((u1-u0)) -v y=$((y1-y0)) -v t=$((t1-t0)) -v n=$((n1-n0)) 'BEGIN{ printf "%-8s %8.0f req/s | CPU per request: user %6.0f us, system %6.0f us, total %6.0f us | cores busy %.2f of 4 | throttled %d periods, %.0f ms\n", c, rps, u/r, y/r, (u+y)/r, (u+y)/12e6, n, t/1000}' done

The whole diagnosis, which starts the two containers, installs strace in them and attaches it to a worker under load (on x86_64 the call is access; for the arm64 counts of the curiosities section I attached strace -f -c -e trace=faccessat,faccessat2,accept to every php-cgi process instead):

#!/usr/bin/env bash # Where does the ZTS slowdown under FastCGI come from? Runs against bench-cgi:8.6.0-nts (NTS) and bench-cgi:8.6.0-cli (ZTS). # 1. CPU per request, user vs system, cores busy, CFS throttling (cpu-split.sh) # 2. the app-independent timer test (timer-test.sh) # 3. syscall counts and durations of one worker under load (strace) # Everything is a container started with --rm and stopped at the end. set -uo pipefail cd "$(dirname "$0")" OUT=runs/diagnosis; mkdir -p "$OUT" docker network create benchnet >/dev/null 2>&1 || true { echo "kernel: $(uname -r)"; echo "cpu: $(grep -m1 'model name' /proc/cpuinfo | cut -d: -f2)"; date -Is; } > "$OUT/env.txt" for pair in "dg-nts:bench-cgi:8.6.0-nts" "dg-zts:bench-cgi:8.6.0-cli"; do name=${pair%%:*}; image=${pair#*:} docker run -d --rm --name "$name" --network benchnet --cpus 4 --cap-add SYS_PTRACE "$image" >/dev/null done sleep 5 for c in dg-nts dg-zts; do docker exec "$c" sh -c 'apt-get update -qq >/dev/null 2>&1; apt-get install -y -qq --no-install-recommends strace >/dev/null 2>&1'; done ./cpu-split.sh dg-nts dg-zts dg-nts dg-zts dg-nts dg-zts > "$OUT/cpu-split.txt" 2>&1 ./timer-test.sh php:8.6.0-nts php:8.6.0-cli > "$OUT/timer-test.txt" 2>&1 for l in nts zts; do c=dg-$l docker run --rm --network benchnet --cpus 2 wrk-native -t2 -c16 -d14s "http://$c:8081/api/items" > "$OUT/wrk-$l.txt" 2>&1 & sleep 4 pid=$(docker exec "$c" sh -c 'for p in $(ls /proc | grep -E "^[0-9]+$" | sort -n); do tr "\0" " " < /proc/$p/cmdline 2>/dev/null | grep -q "^php-cgi" && echo $p; done 2>/dev/null | tail -1') docker exec "$c" timeout 6 strace -c -f -p "$pid" -o /tmp/strace.txt >/dev/null 2>&1 docker exec "$c" cat /tmp/strace.txt > "$OUT/strace-$l.txt" wait done docker stop dg-nts dg-zts >/dev/null echo done > "$OUT/DONE"

The timer test:

#!/usr/bin/env bash # App-independent test of the per-request POSIX timer work that ZTS builds do on Linux (max_execution_timer): # set_time_limit() re-arms that timer (timer_settime) on ZTS and calls setitimer on NTS. We time 200,000 calls in one # process, then in 8 processes at once, on an NTS and on a ZTS build of the same PHP version. # ./timer-test.sh php:8.6.0-nts php:8.6.0-cli for image in "$@"; do echo "== $image $(docker run --rm "$image" php -r 'echo PHP_VERSION," ",PHP_ZTS?"ZTS":"NTS";')" docker run --rm --cpus 8 "$image" sh -c ' one() { php -r "\$n=200000; \$t=hrtime(true); for(\$i=0;\$i<\$n;\$i++) set_time_limit(30); echo round((hrtime(true)-\$t)/\$n),\"\n\";"; } echo " 1 process : $(one) ns per set_time_limit()" for i in 1 2 3 4 5 6 7 8; do one & done > /tmp/par.txt; wait echo " 8 at once : $(sort -n /tmp/par.txt | tr "\n" " ")ns per call, one value per process"' done

The two small demonstrations from the curiosities section, as scripts:

#!/usr/bin/env bash # Does max_execution_time count waiting? set_time_limit(1), then usleep for 2 s (no CPU used) on the four official CLI images. for img in php:8.5.13-cli php:8.5.13-zts php:8.6.0-nts php:8.6.0-cli; do printf '%-18s ZTS=%s ' "$img" "$(docker run --rm $img php -r 'echo PHP_ZTS;')" docker run --rm $img php -r 'set_time_limit(1); $t = microtime(true); usleep(2000000); printf("survived a %.1f s sleep\n", microtime(true) - $t);' 2>&1 | head -2 | tr '\n' ' ' echo done
#!/usr/bin/env bash # Can a thread-safe PHP load an extension built for the non-thread-safe one? Take sodium.so from php:8.6.0-nts and load it into # php:8.6.0-cli (ZTS), and the other way round. Same version, same release, only the thread safety differs. set -u d=$(mktemp -d) for pair in "nts:php:8.6.0-nts" "zts:php:8.6.0-cli"; do n=${pair%%:*}; img=${pair#*:} cid=$(docker create $img); dir=$(docker run --rm $img php -r 'echo ini_get("extension_dir");') docker cp $cid:$dir/sodium.so $d/sodium-$n.so; docker rm $cid >/dev/null done echo "== sodium.so of the NTS image, loaded into the ZTS image" docker run --rm -v $d/sodium-nts.so:/tmp/s.so:ro php:8.6.0-cli php -n -d extension=/tmp/s.so -v 2>&1 | head -8 echo "== sodium.so of the ZTS image, loaded into the NTS image" docker run --rm -v $d/sodium-zts.so:/tmp/s.so:ro php:8.6.0-nts php -n -d extension=/tmp/s.so -v 2>&1 | head -8

CLI and the micro suite

ARG BASE FROM ${BASE} RUN apt-get update && apt-get install -y --no-install-recommends libonig-dev git unzip \ && rm -rf /var/lib/apt/lists/* \ && (php -m | grep -qx mbstring || docker-php-ext-install -j"$(nproc)" mbstring) COPY --from=composer:2 /usr/bin/composer /usr/bin/composer COPY apps/laravel /bench/laravel COPY apps/symfony /bench/symfony COPY cli /bench/cli RUN cd /bench/symfony && php bin/console cache:warmup --env=prod >/dev/null 2>&1; true WORKDIR /bench
#!/bin/sh # usage: run.sh <workload>; prints "<workload> <milliseconds>" for one run, measured inside the container set -e w=$1 now() { date +%s%N; } case "$w" in phpstan) rm -rf /tmp/phpstan; cd /bench/symfony t=$(now) vendor/bin/phpstan analyse --no-progress --level=5 --memory-limit=2G --error-format=raw \ /bench/laravel/vendor/laravel/framework/src/Illuminate/Support \ /bench/laravel/vendor/laravel/framework/src/Illuminate/Collections \ /bench/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent \ --configuration=/bench/cli/phpstan.neon > /tmp/phpstan.out 2>&1 || true e=$(now); echo "errors $(wc -l < /tmp/phpstan.out)" >&2 ;; symfony-cache-clear) cd /bench/symfony; t=$(now) php bin/console cache:clear --env=prod -q e=$(now) ;; composer-dump-autoload) cd /bench/laravel; t=$(now) composer dump-autoload --classmap-authoritative -q e=$(now) ;; laravel-artisan-list) cd /bench/laravel; t=$(now) for i in 1 2 3 4 5 6 7 8 9 10; do php artisan list >/dev/null; done e=$(now) ;; micro) php -d opcache.enable_cli=1 -d memory_limit=1G /bench/cli/micro.php; exit 0 ;; micro-jit) php -d opcache.enable_cli=1 -d memory_limit=1G -d opcache.jit=tracing -d opcache.jit_buffer_size=64M /bench/cli/micro.php; exit 0 ;; *) echo "unknown workload $w" >&2; exit 2 ;; esac echo "$w $(( (e - t) / 1000000 ))"
parameters: tmpDir: /tmp/phpstan reportUnmatchedIgnoredErrors: false
#!/usr/bin/env python3 """CLI benchmarks: every workload runs in a fresh container per image, in rotating order. Images (all official, mbstring added where the official image lacks it): nts85 php:8.5.13-cli NTS what people run today zts86 php:8.6.0-cli ZTS what the official 8.6 image is zts85 php:8.5.13-zts ZTS control: 8.5 built thread-safe nts86 php:8.6.0-nts NTS official NTS 8.6, added to Docker Hub on 2026-11-25 (docker-library PR 1722) """ import datetime import itertools import subprocess import sys IMAGES = {"nts85": "bench-cli:8.5.13-cli", "zts85": "bench-cli:8.5.13-zts", "nts86": "bench-cli:8.6.0-nts", "zts86": "bench-cli:8.6.0-cli"} WORKLOADS = ["phpstan", "symfony-cache-clear", "composer-dump-autoload", "laravel-artisan-list", "micro", "micro-jit"] ROUNDS = int(sys.argv[1]) if len(sys.argv) > 1 else 5 only = sys.argv[2].split(",") if len(sys.argv) > 2 else WORKLOADS stamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") out = open(f"runs/cli-{stamp}.tsv", "w") chk = open(f"runs/cli-{stamp}.checks.txt", "w") out.write("round\timage\tworkload\tcase\tms\n") names = list(IMAGES) for w in only: for r in range(1, ROUNDS + 1): k = (r - 1) % len(names) order = names[k:] + names[:k] # rotate so no image is always first for n in order: p = subprocess.run(["docker", "run", "--rm", "--cpus", "4", IMAGES[n], "/bench/cli/run.sh", w], capture_output=True, text=True) if p.returncode != 0: sys.exit(f"{n} {w} failed:\n{p.stderr[-800:]}") for line in p.stdout.strip().splitlines(): parts = line.split() case, ms = (parts[0], parts[-1]) if w.startswith("micro") else (w, parts[-1]) out.write(f"{r}\t{n}\t{w}\t{case}\t{ms}\n") chk.write(f"== round {r} {n} {w}\n{p.stderr}") out.flush(); chk.flush() print(r, n, w, p.stdout.strip().replace("\n", " | ")[:100], flush=True) print("written", out.name)

The micro suite itself, seven cases that print a checksum each:

<?php declare(strict_types=1); // CPU-bound micro suite. Every case prints "name<TAB>milliseconds" and a checksum // on stderr, so a wrong result on one version cannot hide behind a fast time. function timed(string $name, callable $fn): void { $t = hrtime(true); $sum = $fn(); $ms = (hrtime(true) - $t) / 1e6; fwrite(STDERR, sprintf("%s checksum %s\n", $name, $sum)); printf("%s\t%.1f\n", $name, $ms); } timed('nbody', function (): string { $bodies = []; for ($i = 0; $i < 5; ++$i) { $bodies[] = [$i * 1.1, $i * 0.7, $i * 0.3, 0.01 * $i, 0.02, 0.03, 1.0 + $i]; } for ($step = 0; $step < 300000; ++$step) { for ($i = 0; $i < 5; ++$i) { for ($j = $i + 1; $j < 5; ++$j) { $dx = $bodies[$i][0] - $bodies[$j][0]; $dy = $bodies[$i][1] - $bodies[$j][1]; $dz = $bodies[$i][2] - $bodies[$j][2]; $d2 = $dx * $dx + $dy * $dy + $dz * $dz + 0.01; $mag = 0.001 / ($d2 * sqrt($d2)); $bodies[$i][3] -= $dx * $bodies[$j][6] * $mag; $bodies[$i][4] -= $dy * $bodies[$j][6] * $mag; $bodies[$i][5] -= $dz * $bodies[$j][6] * $mag; $bodies[$j][3] += $dx * $bodies[$i][6] * $mag; $bodies[$j][4] += $dy * $bodies[$i][6] * $mag; $bodies[$j][5] += $dz * $bodies[$i][6] * $mag; } } for ($i = 0; $i < 5; ++$i) { $bodies[$i][0] += 0.001 * $bodies[$i][3]; $bodies[$i][1] += 0.001 * $bodies[$i][4]; $bodies[$i][2] += 0.001 * $bodies[$i][5]; } } return sprintf('%.6f', $bodies[0][0]); }); timed('fannkuch-9', function (): string { $n = 9; $p = range(0, $n - 1); $q = $s = $count = []; $maxFlips = $checksum = $sign = 1; $m = $n - 1; $r = $n; $perm = 0; $count = array_fill(0, $n, 0); while (true) { while ($r !== 1) { $count[$r - 1] = $r; --$r; } $q = $p; $flips = 0; while (($k = $q[0]) !== 0) { $i = 0; $j = $k; while ($i < $j) { $t = $q[$i]; $q[$i] = $q[$j]; $q[$j] = $t; ++$i; --$j; } ++$flips; } $maxFlips = max($maxFlips, $flips); $checksum += $sign * $flips; $sign = -$sign; while (true) { if ($r === $n) { return $checksum . ' ' . $maxFlips; } $p0 = $p[0]; for ($i = 0; $i < $r; ++$i) { $p[$i] = $p[$i + 1]; } $p[$r] = $p0; --$count[$r]; if ($count[$r] > 0) { break; } ++$r; } ++$perm; } }); timed('mandelbrot', function (): string { $inside = 0; for ($y = 0; $y < 400; ++$y) { for ($x = 0; $x < 400; ++$x) { $cr = 2.0 * $x / 400 - 1.5; $ci = 2.0 * $y / 400 - 1.0; $zr = $zi = 0.0; for ($i = 0; $i < 50 && $zr * $zr + $zi * $zi < 4.0; ++$i) { $t = $zr * $zr - $zi * $zi + $cr; $zi = 2.0 * $zr * $zi + $ci; $zr = $t; } if ($i === 50) { ++$inside; } } } return (string) $inside; }); timed('binary-trees-15', function (): string { $make = function (int $d) use (&$make): array { return $d === 0 ? [null, null] : [$make($d - 1), $make($d - 1)]; }; $check = function (array $t) use (&$check): int { return 1 + ($t[0] === null ? 0 : $check($t[0]) + $check($t[1])); }; $total = 0; for ($i = 0; $i < 20; ++$i) { $total += $check($make(15)); } return (string) $total; }); timed('objects-sort', function (): string { $o = []; mt_srand(42); for ($i = 0; $i < 300000; ++$i) { $o[] = new ArrayObject(['k' => mt_rand(), 'n' => 'name' . $i]); } usort($o, static fn (ArrayObject $a, ArrayObject $b): int => $a['k'] <=> $b['k']); return (string) $o[0]['n']; }); timed('strings-regex', function (): string { mt_srand(7); $text = ''; for ($i = 0; $i < 60000; ++$i) { $text .= 'user' . mt_rand(1, 9999) . '@host' . ($i % 17) . '.example.com, ' . str_repeat('lorem ', 3); } $n = preg_match_all('/[a-z0-9]+@host\d+\.example\.com/', $text, $m); $up = strlen(strtoupper($text)) + count(explode(',', $text)) + strlen(str_replace('lorem', 'ipsum', $text)); $h = ''; for ($i = 0; $i < 200000; ++$i) { $h = md5($h . $i); } return $n . ' ' . $up . ' ' . $h; }); timed('json-array-funcs', function (): string { $rows = []; for ($i = 0; $i < 20000; ++$i) { $rows[] = ['id' => $i, 'name' => 'row ' . $i, 'tags' => ['a', 'b', (string) ($i % 7)], 'score' => $i / 7]; } $sum = 0; for ($r = 0; $r < 8; ++$r) { $json = json_encode($rows); $back = json_decode($json, true); $sum += count(array_filter(array_map(static fn (array $x): int => $x['id'] * 2, $back), static fn (int $v): bool => $v % 3 === 0)); $sum += array_sum(array_column($back, 'id')); } return (string) $sum; });

The statistics

The bootstrap behind the "how many rounds" chart, exactly as I ran it (20,000 resamples, seed 8086), and the arithmetic of the fleet chart: containers = ceil(peak load / (measured requests per second x target utilisation)).

RESAMPLES = 20000 SEED = 8086 def bootstrap(a: list[float], b: list[float], n: int, rng: random.Random) -> float: """Share of resamples (n rounds drawn with replacement from each image's eight) in which the 8.6 median is below the 8.5 median.""" below = 0 for _ in range(RESAMPLES): below += st.median(rng.choices(b, k=n)) < st.median(rng.choices(a, k=n)) return 100 * below / RESAMPLES

How this was measured

Two machines. A server with an AMD Ryzen 9 9955HX (16 cores), Ubuntu 26.04.1, Linux 7.0.0-44, Docker 29.10.0 and the CPU frequency governor on powersave, on amd64 images. A MacBook with an Apple M1 Pro on macOS 27.2.1, Docker Desktop 29.9.3 with an 8-CPU, 7.65 GiB Linux virtual machine, on arm64 images, with my other containers stopped for the runs. Laravel 13.44.1 on SQLite with sessions in memory, Symfony 8.1.12 with Twig 3.31.1, PHPStan 2.3.7, Composer 2.11.1, wrk 4.2.0 built natively. Every server container was limited to 4 CPUs and wrk to 2.

Every percentage in this article is a relative change of a median unless it says "points"; the gap between two such changes is in percentage points, and the bootstrap charts show shares of resamples.

Every row is the median of five rounds (eight for php-fpm), with the minimum and maximum shown where they matter. The builds took turns going first so that thermal drift and cache state did not favour one. I removed no round and discarded no outlier. The thread safety, extensions and version of each image were read from the images themselves, and I kept the configure flags of the builds. The CLI and micro series ran earlier than the HTTP ones, in a separate session each.

What I did not test: open-loop load at a realistic utilisation (every run here saturates its container, which is also why p99 measures the CPU quota), Alpine or Apache images, worker mode, a database server instead of SQLite, a long-running soak (a leak would show up there, not in 20-second windows), the JIT under HTTP load, and a php-fpm build without thread safety, since none exists as an image. The micro suite says nothing about your hot path, only about the interpreter. Every number in this article is recomputed from the raw run files by a script that fails if the text and the runs disagree.

Related Articles