1

We've got a AWS setup with an ELB in front, 2 varnish cache servers and 2 Craft CMS backends, with Redis for php sessions and Craft cache shared amongst the backend servers.

We do not have sticky sessions, so each request can end up on a different server.

Problem is with cpresources and the generated files. First request generates files on server 1, but as each request can end up on a different server, the other servers will not have the same files.

What is the best approach here? What alternatives do we have?

We would like to avoid sharing cpresources amongst the servers if possible (via mount), as it slightly complicates setup and its "one more thing that may break".

-- Edit

We have been experimenting with AWS EFS (Elastic File Storage) to share disks between servers, but unfortunately its too slow.

We noticed that in Craft CMS 2, static files were served through index.php, which allows php to create the files, should they not exist, which would solve this particular issue. However, in Craft CMS 3, this changed and they are served directly. It would be great if someone official in Craft CMS could verify this change and comment why it was designed the way it is in Craft CMS 3 and also comment on how that change is beneficial in a multi-backend-setup.

We are now looking into an EC2 instance to serve the purpose of an NFS share, but doing this we are introducing a single point of failure in an architecture that was suppose to eliminate that exact thing.

2

Running into the same issue here!

For the uploaded files I have solved it by creating a NFS share on all backends (15 servers). Not ideal but it's working for now. Maybe mounting the cpresources to NFS share would also do the job, but I haven't tested it.

| improve this answer | |
0

It seems this is actually already solved from 3.0.13 https://github.com/craftcms/cms/issues/2500 and onwards, but the reason it did not work was because of how the webserver was configured (nginx, apache).

By directing requests for these type of files to index.php instead Craft will handle generating the files should they be missing.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.