I want to run Drupal from a cloud and I am trying to figure out the design of the file system for multi-site setup.
In the cloud, there are multiple servers hidden under the load balancer which serve content from a single database (a service that handles replication on its own) and using central storage for user or Drupal data.
I solved the problem for user data, mostly images attached to nodes or uploaded via fields, but I'm stuck on how to handle files like compiled Twig templates, configuration files, services file, and similar files.
Once a new server instance is created, it will fetch the code from a Git repository. The user data is handled via a stream wrapper (and CDN); no action is needed.
How should I handle the system files?
The more static files like the settings.php and services.yml files could be potentially stored in some "remote" storage and fetched from there, or they could be dynamically generated based on data stored in a special database.
What about the other files (template and configuration files, for example)?
Would something like a fast cache be a good design?
A Redis database could hold the current files; each instance could either fetch them manually or serve them directly. Once an instance flushes the cache, this would be immediately "synchronized" to all the instances, in second scenario. For first scenario, there could be timestamp value for latest change that each instance would check on each page load to re-fetch the files when necessary.