Search
Varnish Controller

Multiple Regions

Let’s say we want to deploy a VCLGroup to a set of agents in the US and a set of agents in Asia. We want to use the same VCL files for all servers. This would require the following:

  • Agents in the US will be tagged with a tag named US
  • Agents in Asia will be tagged with Asia.
  • One deployment configuration will have the tag US
  • Another deployment configuration will have the tag Asia
  • One VCL will be created that should run on all servers, no matter which region.
  • The VCLGroup will be assigned both deployment configurations.
  • The VCLGroup will be assigned the created VCL.

Let’s assume we have two agents running, the one with ID 1 runs in the US. The other with ID 2 runs in Asia. The CLI commands to achieve the above would be (for further CLI examples, see the CLI chapter).

# Create tags
vcli tags add US Asia

# We assume US tag got ID 1 and Asia got ID 2. We tag agent 1 with US and agent 2 with Asia.
vcli agents tag 1 --tag 1
vcli agents tag 2 --tag 2

# Upload a VCL from the file my.vcl (assumed to get ID 1)
vcli file add main.vcl my.vcl

# Create a domain (assumed to get ID 1)
vcli domains add example.com

# Create a deployment for Asia and one for US
vcli dep add depUS --tags 1 --max 10
vcli dep add depAsia --tags 2 --max 10

# Now create a VCLGroup to use on both regions (both agents)
# Deployments 1 and 2, domain 1 and VCL 1
vcli vg add myVG --dep 1,2 --dom 1 --vcl 1

# Now deploy it
vcli vg deploy 1

Creating tags and assigning them to agents is usually something you do once.

If we want to update the VCL and automatically deploy it, we can just edit the VCL:

vcli file edit 1

When saving the VCL and it compiles correctly, it will be automatically deployed to both agents since the VCLGroup itself is already deployed.

Since we specified --max 10 for our deployments in this example the system will automatically add the VCL to all new agents up to 10 agents if they had the correct tags that the deployment has specified. If there are 20 agents matching and one of the used 10 agents goes down, a new randomly chosen agent will be used for deployment to fulfill the maximum of 10 agents.