Problem/Motivation
As #2547827: PhpStorage: past, present and future documented, currently Drupal 8 can't be used on multiple webheads without writing files to a shared filesystem. This is undesirable because a shared filesystem at best is slow at worst doesn't exist at all if stream wrappers are used to store upload files on some mass file hoster.
Proposed resolution
- Use the extension classes + mtime to invalidate template files, once any of those change. This is done using a hash of those values
The following solutions have been proposed:
- Add the value of a distributed atomic counter to the file name of the local file. When invalidating the storage, increase the counter. Drawback: it requires an atomic counter query for every read. By default this comes from the database which is a performance hit.
- Use the cache as phpstorage in such a way that included files can still be opcode cached. Drawback: since the name of the wrappers that can be opcode cached is hardwired in PHP 5.5-7.0 this is necessarily a hack. We do not want to add hacks to core so this is moved to contrib.
- Do not solve the problem in general, just make core work. Change the container to not use phpstorage at all. For Twig add a hash of the things the compiled code can vary on (core version, deployment identifier, twig extensions) to the file name. Drawback: every web frontend needs a local writable disk and also each will need to compile every Twig file for itself which is a small waste of effort (not too big). These are inherent to this solution and are not fixable. The solution in the previous point does not use a disk at all and it's possible to change it via some kind of locking to have only one process building.
Remaining tasks
User interface changes
API changes
Data model changes
Beta phase evaluation
Issue category | Bug, because templates are maybe not invalidated, even they should |
---|---|
Issue priority | Critical, because serving wrong output could lead to all kind of problems. |
Disruption | Existing sites would need to update all their dumped twig files (this happens implicit), so there is no actual problem. |