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".
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.