简体   繁体   中英

Storing TYPO3 cache files in AWS EFS

I have an application built on TYPO3 CMS and its hosted on AWS. The architecture is like this:

  1. Auto scaling Group
  2. Load Balancer
  3. Two instances hosting the application

sometimes when opening the application, we have a PHP error :

The temporary cache file /var/www/htdocs/typo3temp/Cache/Code/fluid_template/file.tmp could not be written

The Exception is generated by the file FileBackEnd.PHP

   if ($result === false) {
       throw new \TYPO3\CMS\Core\Cache\Exception('The cache file "' . $cacheEntryPathAndFilename . '" could not be written.', 1222361632);
   }

The full content of the file HERE .

I guess the reason of this error, is because the load balancer is sending traffic to the other instance where the file was not generated. AM I right ?

To resolve this error, I am thinking of instead of storing the temporary files in the volumes of the instances, we should store them on a shared EFS. Is that technically, TYPO3 wise, possible ?

PS: TYPO3 v6.2

Thank you.

In the fileadmin file storage record , you may specify the path for temporary files - and use a different file storage for them.

So create a new AWS file storage, and set the fileadmin temp directory to a directory in that new file storage. See the documentation at https://docs.typo3.org/typo3cms/FileAbstractionLayerReference/singlehtml/Index.html#processed-files

This answer applies mostly to the specific Fluid caching but can also be used on other caches, but should not be used on caches like "cache_core" which is essential. You've got a couple of options:

  • You can mark the particular cache "frozen" which means no new entries will be allowed. An exception will be thrown if trying to set in a frozen cache.
  • You can distribute the specific filesystem location containing the files (but you should be careful not to distribute too much, as this can negatively impact performance on some scaling setups).

I think you want the second option here which allows expired or new Fluid cache entries to be written, but distributes the resulting class files so they may be loaded on any of the slaves.

The frozen cache is only an option if you are able to 100% pre-generate all the compiled Fluid classes (which depending on your setup may not even be possible with a full crawl of the site).

Unfortunately you are on TYPO3 6.2 - had you been on v8 I would certainly recommend https://github.com/NamelessCoder/typo3-cms-fluid-precompiler-module as a nice way to control where those classes get compiled and stored in a cache, and catching all templates (when they exist in standard paths).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM