Answers.Body: <p>It seems this is actually already solved from 3.0.13 <a href="https://github.com/craftcms/cms/issues/2500" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/2500</a> and onwards, but the reason it did not work was because of how the webserver was configured (nginx, apache).</p>
  
  <p>By directing requests for these type of files to index.php instead Craft will handle generating the files should they be missing.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T09:49:39.430Z
Answers.LastActivityDate: 2019-03-19T09:49:39.430Z
Answers.UserDisplayName: termi7e
Answers.Body: <p>Running into the same issue here!</p>
  
  <p>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. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-04T11:41:00.313Z
Answers.LastActivityDate: 2019-03-04T11:41:00.313Z
Answers.UserDisplayName: Arjan
Body: <p>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.</p>
  
  <p>We do not have sticky sessions, so each request can end up on a different server.</p>
  
  <p>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.</p>
  
  <p>What is the best approach here? What alternatives do we have?</p>
  
  <p>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".</p>
  
  <p>-- Edit</p>
  
  <p>We have been experimenting with AWS EFS (Elastic File Storage) to share disks between servers, but unfortunately its too slow.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
Tags: <setup>
Title: Multiple backends on CraftCMS 3 - Problem with cpresources
ThreadText: # Multiple backends on CraftCMS 3 - Problem with cpresources
  
  (Asked by: username_0 on 2019-03-04)
  
  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.
  
  **Tags:** setup
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-03-19. Score: 0 | Accepted answer
  
  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.
  
  
  ---
  
  ### Answer by username_1 on 2019-03-04. Score: 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.
  
  
  ---
  
  