Repository navigation
Description
#1686 switched all 8.6+ images to ZTS and dropped NTS builds entirely. I'd like to ask for this to be reconsidered, or at least softened, before 8.6.0 GA, because it appears to anticipate an upstream decision that hasn't been made yet.
Upstream status, as far as I can find:
- The only internals discussion is a pre-RFC from July 2026 ("Deprecating NTS and making ZTS the default build mode", https://externals.io/message/131870). It targets NTS removal for PHP 9.0, not 8.6.
- There is no RFC on wiki.php.net and no vote.
- In that thread, a core developer explicitly asked for proper benchmarks under different loads (FPM, Apache prefork) before accepting the "negligible overhead" claim, since performance is the main reason two build modes exist. I couldn't find those benchmarks published anywhere.
- [PHP 8.6] switch the default from NTS to ZTS #1673 mentions being told that no RFC is needed for build changes, but I couldn't find that statement in the public thread. If it exists, a link would help.
#1689 describes the change as "PHP upstream recommended that we switch the images to use ZTS by default". As far as I can tell, that recommendation came from the author of the pre-RFC in #1673, not from a decision of the PHP project: there is no accepted RFC, no vote, and no release-manager statement that I could find. If there is an official upstream statement I've missed, please link it and I'll gladly close this.
Why this matters for these images specifically:
For many users, php:<version>-cli / -fpm is PHP. Switching them to ZTS-only effectively makes ZTS the default for a large share of the ecosystem before upstream has decided to do so. It could also later be cited as evidence in that very RFC ("everyone already runs ZTS"). The images have historically followed upstream defaults (NTS by default, ZTS as an opt-in variant), and I think that is the right policy here too.
There are also practical concerns:
- NTS is still the upstream default build in 8.6, and it is what essentially every major distribution ships: Debian/Ubuntu, Alpine, Arch, Fedora/RHEL (ZTS is an off-by-default build conditional), FreeBSD ports (ZTS is an off-by-default option), and Homebrew (explicitly no thread-safe build). With remove zts, instead all images are always built as zts (8.6+) #1686, the 8.6 images become the only mainstream PHP source that is ZTS-only, so behavior in containers will diverge from what extensions and benchmarks are usually tested against.
- Overhead of ZTS for single-threaded CLI/FPM workloads is claimed to be small, but it hasn't been demonstrated with published, reproducible benchmarks.
- Some extensions and features still don't support ZTS (e.g.
--with-mmsession handler, some third-party/commercial extensions such as APM agents).
Request, in order of preference:
- For 8.6, keep the previous layout: NTS for
cli/fpm/apache, with ZTS available as the-ztsvariant. Revisit when an RFC is accepted upstream (most likely for 9.0, where the question resolves itself). - If that's not acceptable, at least publish
-ntsvariants for 8.6 so users have a supported migration path, and document the change prominently in the image description / release notes.
Thanks for maintaining these images. I'm not against ZTS as such. I'd just like the official images to follow upstream's decision rather than get ahead of it.
Refs: #1673, #1686, #1689, https://externals.io/message/131870
Activity
tianon commentedon Nov 19, 2026
cc @henderkes 🙇
FWIW, I've had a paperclip counter help write some benchmarks to chase various PHP threads, including ZTS overhead, and the results can be seen in the actions on https://github.com/infosiftr/php-bench
From https://github.com/infosiftr/php-bench/actions/runs/43888110981 (the latest report):
...
...
...
CPU: what does the thread-safe (zts) build cost? -- #742
henderkes commentedon Nov 19, 2026
The proposal to switch the Docker images ahead of time came from a php internals slack discussion - it didn't come from me. The idea being to get a grasp on what NTS-only features would actually need to be kept (mm session backend, chroot function, hard timeouts, signal handling, timeout handling). Most of these are half-broken that just haven't been removed yet.
I'm not necessarily against keeping NTS available for now, but I would like to hear the actual issues you're currently running into. 8.6 went into GA as of 2pm yesterday.
(Edit: The reason this is starting with the Docker images and not elsewhere is simple: the docker extension installer already had full ZTS support. For distributions it would've meant a larger change.)
henderkes commentedon Nov 20, 2026
These numbers look a lot like <= PHP-8.5 values. Are you sure they are from 8.6? There will still be overhead in the worst case scenarios, as the globals move didn't make it in before 8.6 was branched, but it shouldn't be anywhere near +19% in any case, even with recursive TLS reloading and the JIT still emitting a TLS load rather than direct access instruction (also merged in master).
tianon commentedon Nov 20, 2026
henderkes commentedon Nov 20, 2026
I copied the 8.6-cli dockerfile into a NTS variant and ran your suite:
https://github.com/henderkes/php-bench/actions/runs/44659928397
But I wouldn't put too much faith on the numbers being faithful due to CI runners unstable nature. <= 5% differences are hard to measure, even on mostly stable local hardware. The jit slowdowns are probably real, but anything other than that should be at <= 2% difference.
I'll run the numbers later on a stable cloud runner, but it's a 4 core machine so that'll take a while.
roxblnfk commentedon Nov 20, 2026
Thanks for the context and for running the suite on 8.6.
What we have already run into. We maintain Rapira, an application server by the RoadRunner maintainers. Rapira only works with NTS, and we relied on the NTS builds of the official images. With 8.6 those builds are gone, so we had to publish our own:
ghcr.io/rapira-rs/php:8.6-nts. For users, this means moving away from the official images to get the build that is still the default in PHP itself.What users will run into. The floating tags (
latest,8,fpm,8-fpm,apache,alpine, …) already point to 8.6, so the change of build mode arrives with a plaindocker pull, without any warning. The problems show up at runtime:chdir()only changes PHP's virtual CWD, so native code (FFI, libraries used by extensions) may see a different working directory;chroot) are core functionality for long-running workers;Where the decision was made. Could you clarify which "php internals slack" this was? If it's the PHP Foundation's Slack, I'd point out that the Foundation funds development but doesn't decide the direction of the project. Those decisions go through the internals list and the RFC process. @DanielEScherzer, @mbeccati, as the 8.6 release managers, were you part of that discussion, and do you support switching the official images to ZTS-only? #1689 currently describes this as "PHP upstream recommended…", and users read that as the position of the PHP project.
Proposal. Since 8.6 is GA now and you're not against keeping NTS available, could the images publish
-ntsvariants for 8.6 (mirroring the previous-ztsones)? Either way, a note in the Docker Hub description (docker-library/docs) would help: right now it doesn't mention anywhere that 8.6 is built as ZTS. The only explanation is the closed #1689, while users oflatest/fpmget the change through a regulardocker pull.henderkes commentedon Nov 20, 2026
As long as you use the CG/EG/SG/etc macros like php-src instead of relying on direct struct access, it should work perfectly fine with a ZTS build. But yeah, I can see that it may have broken your expected upgrade.
I think that's the biggest issue, but at least for php-src there's no forward compatibility promise between minor versions. E.g. 8.6 can (and will) have other breaking changes than the ZTS default.
Like I said, don't read too much into these. For one, because they're not representative of real world load, second, because the CI runners are very unreliable. :
My local run came in at an average 1.5% slowdown
Yes, the foundation slack, which isn't only used for foundation work, but also has community channels with plenty discussion about all sorts of non-official work. A ZTS switch suggestion doesn't constitute any php foundation involvement. There was no formal "decision".
Quoting myself from #1673:
I don't see a reason against it. Though it would be helpful if you could actually detail exact breakage that you're encountering if you attempt switching to ZTS. That's the largest reason for why it was even suggested: see what breaks while there's still a way to fix it. If nobody tests until NTS doesn't exist anymore, we'd have no idea until it was too late.
FYI, I'm absolutely planning on keeping hard-timeouts, maybe even the zend-mm backend. A ZTS-only build doesn't necessitate dropping that functionality, it would just have to restrict it to single-threaded SAPI usage (like CLI, FPM).
roxblnfk commentedon Nov 20, 2026
Thanks for the detailed reply and the local numbers.
On #1689, I'd point out an inaccuracy there: it describes the change as "PHP upstream recommended that we switch the images to use ZTS by default". By your account, this came from a discussion in a community channel of the Foundation's Slack, and "there was no formal 'decision'". So there was no upstream recommendation, only a suggestion by some contributors and a pre-RFC that never became an RFC.
On "see what breaks": the goal makes sense, but changing the default is a poor way to reach it. The opt-in
-ztstags existed for years, and they were the way to test ZTS. People whose setup breaks after adocker pullusually have no reason to come here and report it. They just pin 8.5 or move to other images, as we had to. So this is more likely to produce incomplete data than a real picture. Rapira's ZTS compatibility is a separate topic, and this issue is about the default of the official images. As for compatibility between minor versions: this change doesn't come from PHP 8.6. It's not in UPGRADING or in the image description, so users have no way to expect it.@tianon, @yosifkit, since there was no formal upstream decision, could 8.6 go back to the previous layout: NTS in
cli/fpm/apache, and ZTS as the-ztsvariant? 8.6.0 was released only yesterday, so a revert now affects far fewer users than it would later, once 8.6 has spread to production through the floating tags. The only consequence we know of is that downstream images that already switched toclias their ZTS base (for example FrankenPHP in itsdocker-bake.hcl) would need to switch back to-zts, a one-line change.If reverting the default isn't acceptable to you, then at least
-ntsvariants for 8.6, as the original proposal in #1673 already suggested. Either way, we're happy to help with a PR.UPD: besides ZTS itself, the 8.6 images come with two more behavior changes that aren't mentioned anywhere:
--disable-zend-signals. This flag used to be only in the-ztsvariant, while upstream has Zend Signals enabled by default.max_execution_time/set_time_limit()now measures wall-clock time (CLOCK_BOOTTIME) instead of CPU time (ITIMER_PROF). Time spent insleep()or waiting on a database, HTTP or a queue now counts, while before it didn't. The timeout signal is also different: a thread-directed SIGRTMIN instead of SIGPROF.To reproduce:
Both changes make sense for a ZTS build. But for users of
latest/fpm, it means that after a regulardocker pull, scripts with an explicit time limit that wait on I/O may start failing with a timeout without any change in their code.henderkes commentedon Nov 20, 2026
I don't mind your suggestion, but please understand that
clearly went without great effect. People use the default or get confused when put before a choice, especially one like NTS vs ZTS, where most information google will dig up is a decade old. That default was/is ZTS for FrankenPHP/parallel/Windows*/Apache users and NTS for Unix/RoadRunner/FPM/CLI.
I don't believe the default switch will/would affect most users in a noticeable way.
rustatian commentedon Nov 20, 2026
RoadRunner does not depend on PHP thread safety (you can use any PHP, zts or nts).
henderkes commentedon Nov 20, 2026
Yes, my understanding is that Roadrunner is based off cli, meaning it gets the unix default of non-apache/frankenphp, which is NTS. Generally no SAPI should depend on php being NTS internally (that's what the global accessor macros exist for).
roxblnfk commentedon Nov 20, 2026
Users do mostly go with the default, which is exactly why changing the default affects them. But NTS for FPM/CLI isn't a leftover from outdated search results. It's the project's current recommendation: windows.php.net says that "NTS builds are for single-threaded use cases, typically PHP running via FastCGI or on the CLI", while TS builds are for PHP loaded as a web server module. Users who need ZTS (FrankenPHP, parallel) already had
-ztsavailable.This issue isn't about SAPIs. It's about behavior that users of the image get without any change in their code. The example from the UPD above is a plain script:
set_time_limit(2); sleep(4);passes onphp:8.5-cliand fails with a fatal error onphp:8.6-cli, becausemax_execution_timenow measures wall-clock time instead of CPU time.xepozz commentedon Nov 20, 2026
Macros are fine (and I don't know why it is even a point), but they do not change how SAPI works (NTS or ZTS or both). Moreover, usually, if SAPI is not written in C/C++, you're using them from a shim layer, because in Rust or Go you can't use them directly.
I think that is the reason why these images were so quickly changed to ZTS.
henderkes commentedon Nov 20, 2026
No, switching the default doesn't directly benefit FrankenPHP. The immediate advantage is deduplication. There's thousands(+++) of build hours wasted every week because two versions of the same engine exist. It incurs extra work for every packager like Remi (RPM, who maintained two partial builds for a long time and still updates the old streams), Shivam (Homebrew/Windows) Michele (Docker extensions), countless others and myself. And, obviously, the Docker team here, who are also volunteering their work.
If you're asking why it's NTS that should go: they're 99% the same, except that one can handle multiple threads while the other can't.
rustatian commentedon Nov 20, 2026
While I completely agree that having 1 mode would be great, it doesn't solve the duplication problem in any way. You just made things more complicated for other SAPIs to use official PHP images by breaking them in a way that, for example, I, as a Rapira maintainer, can't use them anymore because they're ZTS-only now. For other people, that change will also very likely introduce surprises in their apps' behavior because of the reasons stated above.
So, my simple question is: what problem does that action actually solve?
40 remaining items
Yoskaldyr commentedon Nov 22, 2026
I guess someone forgot to tell the PHP developers that adding FFI support to PHP was almost exclusively a bad idea.
Perhaps we should just remove FFI from PHP instead of fixing compatibility issues?
P.S. The more you explain why users shouldn't rely on existing PHP functionality, the better you demonstrate why they shouldn't rely on these Docker images either.
SerafimArts commentedon Nov 22, 2026
To begin with, I was branded a bad developer ("Write bad code making ungoverned internal assumptions, get bad results") - my qualifications were called into question, and I was told that, instead of just using a simple
chdir, I should write something like this (and fix "ZTS feature" using FFI): https://github.com/php-ffi/work-directory/blob/master/src/Driver/WindowsThreadSafeDriver.phpThen I was advised to drop FFI entirely, simply because "It's nearly impossible to actually make it safe with exception handling and vm bailout logic as is" (though why would anyone even try to make something safe when it’s meant to be low-level, efficient, and inherently unsafe?) - and all without offering any alternatives.
...
Thanks, I understand your arguments. I think we can end the conversation here =)
Honestly, it might be easier to just give up on PHP altogether - after all, it has "unsafe exceptions".
NathanFreeman commentedon Nov 23, 2026
As a Swoole maintainer, I would like to share a practical architectural limitation we encountered while adapting to ZTS. In SWOOLE_PROCESS mode, the master process's event loop relies heavily on the multi-reactor threading mechanism to dispatch I/O events. Constrained by the current thread-safety mechanisms of ZTS, and to ensure runtime stability, we are forced to restrict reactor_num to 1 in the master process.
While this does not affect the fundamental operation of Swoole, it is indeed a functional compromise for users who rely on the multi-reactor architecture to handle high-concurrency connections. This is also a major reason why the official Swoole Docker images currently continue to recommend the NTS version by default.
henderkes commentedon Nov 23, 2026
Hi Nathan, thank you for the report. Can you describe the limitation in a bit more detail (and possibly link to swoole-src parts) explaining how thread safety (or the location of the globals?) negatively affects file io? I'm not familiar enough with Swoole to understand why ZTS is a problem in process mode.
My initial thought is that running two reactor threads calling into php concurrently should be fine in ZTS while it would have to serialise in NTS or dispatch to different processes. The latter should also work for ZTS or not? I'm probably missing something.
tianon commentedon Nov 23, 2026
A bit of context on why #1722 looks the way it does, since a few comments have said we're missing the point.
I think the point is "NTS should stay the default until PHP upstream decides otherwise", and I do hear it. That's the part of the ask we're leaning toward saying no to, and here's why.
Released vs unreleased
This change has been public in this repo, and published as pre-release images, for months. The reason it waited for 8.6 (and didn't happen in 8.5 or earlier) is that a new minor release is the one place we can make a change like this without breaking something that was already released.
8.6 is released now. Flipping the default back wouldn't just be another behavior change, it would be a breaking change to an image people are already running, days after GA, which is exactly what the 8.6-only timing was meant to avoid. #1722 is purely additive instead: it adds an
ntsvariant for 8.6 (built the way it was before #1686) andztsaliases forcli, and everything else stays as published at GA. Nobody who's fine today sees any change, and anyone who needs NTS gets a supported way to ask for it.Who we're hearing from
Around 105 distinct accounts have taken part in this thread so far (commenting, being mentioned, subscribing, or reacting), and they're real, and they're why #1722 exists. They aren't the whole picture though. Docker Hub pull data for
library/phpfor the week to 2026-11-23 (lower bounds, with mirrors and multi-pull sessions filtered out):latestand other unversioned tags stayed flat after they moved to 8.6 (~370/day beforehand, ~330-470/day since), and we don't see any move back to 8.5 beyond what the same-day security release explains for 8.3 and 8.4 tooSo people on the moving tags have mostly stayed put, and the folks in this thread are a small slice of the people 8.6 already reaches. It also isn't a clean "upstream vs users" divide: there are people with PHP upstream involvement on both sides of this thread.
If something about the images is still a problem even with
ntsavailable, please say so here. For behavior differences in ZTS itself, php-src is the right place, since that's outside what we can do here.smirnov-e commentedon Nov 24, 2026
Those statements contradict each other.
Those who are fine with switching NTS -> ZTS are perfectly fine to switch ZTS -> NTS anytime, so no breaking change for them. @henderkes promised full compatibility.
The likely reason is that
latestmostly used by libraries and frameworks in CI environment as a reminder «don't forget to update / your code will break in latest PHP». They don't check basic features likemax_execution_time, except for those who use FFI or other advanced features.NathanFreeman commentedon Nov 24, 2026
Hi @henderkes , I'm very sorry, please disregard my previous message. I forgot that this issue was fixed quite a while ago.
ZTS only conflicts with --enable-thread-context. --enable-thread-context is also a multi-threading mode, which is why it conflicts with ZTS.
DeveloperRob commentedon Nov 24, 2026
(It is worth noting I am a PHP developer as opposed to a C developer, so the impact for me is as an end-user, not someone who has to work with differences directly; further to this then within the software I work with then we don't use FFI or any of the other functionality adversely affected)
In respect to the change itself - I support the change of the default (and the eventual removal of
NTShopefully), although I do think having a-ntsvariant for those who want to use 8.6NTSmakes sense. The reasoning for this is if that currentlyZTSis treated as a second class citizen in my opinion - as seen in respect of theNewRelic ZTSextension; but also in extensions that provideZTSsupport, however asNTSis used more widely currently give bug reports that affectZTSonly a fairly low priority - and in at least some cases the bugs occur only becauseZTSisn't considered when code is being written, as opposed to it being harder to support or anything. I fully understand the performance impact from older PHP versions, however I would be interested if there is a noticeable real world effect with the latest versions - but even if there is, my +1 is that resolving that and simplify the options for end users is the best approach.In respect to the change here, I would strongly be against a change for the default for 8.6 now it has been released. Taking the latest comment from @smirnov-e then we knew PHP8.6 was coming out last week; and were able to set aside time to monitor our CI that uses the floating
latesttag to see if there were any issues. (We did, although from the removal ofPECLas opposed to this change.) That is a very different situation to a change being made now, or being made when 8.6.1 comes out where we don't expect any issues to occur with the build tooling for a patch release.Revert: Handle the PHP 8.6 Docker ZTS situation
Revert: Handle the PHP 8.6 Docker ZTS situation
DanielEScherzer commentedon Nov 28, 2026
@tianon can I also request NTS builds for apache images? Should I send a PR for that?
henderkes commentedon Nov 28, 2026
I'm sure they would be happy to oblige, but hasn't php.net warned against using prefork mpm apache for a decade? I recall seeing that warning.
henderkes commentedon Nov 28, 2026
https://www.php.net/manual/en/install.unix.apache2.php
DanielEScherzer commentedon Nov 28, 2026
In that case, is there a NTS version of FPM image?