0

I am wondering how I can dynamically increase and decrease the number of varnish instances for a Magento2 installation as needed - with an aws autoscaling group, for example.

Configuring them from the client side is easy: I can just use a load balancer. But Magento2 also needs to be aware of each instance, and this seems to be a bit more tricky. Updating the configuration file would require an app:config:import, which is a bit of a hassle in a production multi-server environment.

The Magento documentation suggests this command:

magento setup:config:set --http-cache-hosts=192.0.2.100,192.0.2.155:6081

(https://devdocs.magento.com/guides/v2.2/config-guide/varnish/use-multiple-varnish-cache.html)

Is it an appropriate way to update the varnish servers continuously in an operational / live / production system?

1 Answer 1

1

The best way that I've found to do this is to write a PHP script that utilizes the AWS PHP SDK to get a list of all the current instances of your auto-scaling group:

https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-autoscaling-2011-01-01.html#describeautoscalinggroups

That PHP script can then use the command you mentioned on all the production instances. I don't believe there's any better way to do it than that, and has been used in production instances with success.

2
  • Sounds good! - Do you know if the command can be run in a production system without any negative impact?
    – hey
    Commented Jan 17, 2019 at 1:10
  • 1
    Yes, absolutely. :) Of course, always test things on staging, it never hurts! Commented Jan 17, 2019 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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