Zend certified PHP/Magento developer

Managing Cache prefixes and database numbers in multi vm environment

I am hosting Magento through Google Cloud and have each store including the admin running on its own VM behind a load balancer.

My concern was I was running into issues during di:compile. When I removed my redis cache configurations from env.php my problems went away, so I’m assuming it’s because the admin and both stores are all using the same database numbers for session and frontend caches.

My issue is that I have one base VM that I have a deploy script that I run and it compiles the app and gets it ready to deploy to each instance group.

I tried using getenv() within env.php but it always returns false, even tho I verified the environment variables I set were able to get printed with the expected values.

What is the best way to go about solving this, so each website and the admin all have their own specfic id_prefixs and database numbers?

I’m currently going to not use one image and simply create three separate images which will have their separated prefixes and database numbers per website and deploy those.

The problem with that is I have to turn on three VMs. Deploy one, wait for completion, deploy the next, rinse and repeat. This will move my maintenance windows from about 6-8 minutes to probably near 30 minutes.

So while I can essential work around this, I would rather see what others are doing to avoid such a cumbersome implementation.