Custom VCL with multiple backends and director


#1

Hi,

I am attempting to upload a custom VCL to my service and I’m encountering the following error:

A backend that requires a hostname to be resolved must be dynamic at:
.host = “myapp2.mysite.com”;

My overall question is: Can I initialize multiple backend servers with static hostnames in custom VCL, along with a client director? If so, why is Fastly returning this error?

Thanks,
stanlee

Part of my custom VCL:

backend app2 {
    .host = "myapp2.mysite.com";
    .port = "3000";
    .connect_timeout = 3s;
    .probe = {
        .url = "/_healthtest.cfm";
        .timeout = 3s;
        .interval = 5s;
        .window = 5;
        .threshold = 3;
    }
}

backend app3 {
    .host = "myapp3.mysite.com";
    .port = "3000";
    .connect_timeout = 3s;
    .probe = {
        .url = "/_healthtest.cfm";
        .timeout = 3s;
        .interval = 5s;
        .window = 5;
        .threshold = 3;
    }
}

backend app4 {
    .host = "myapp4.mysite.com";
    .port = "3000";
    .connect_timeout = 3s;
    .probe = {
        .url = "/_healthtest.cfm";
        .timeout = 3s;
        .interval = 5s;
        .window = 5;
        .threshold = 3;
    }
}

backend app5 {
    .host = "myapp5.mysite.com";
    .port = "3000";
    .connect_timeout = 3s;
    .probe = {
        .url = "/_healthtest.cfm";
        .timeout = 3s;
        .interval = 5s;
        .window = 5;
        .threshold = 3;
    }
}

director mysite client {
    { .backend = app2; .weight = 100;}
    { .backend = app3; .weight = 100;}
    { .backend = app4; .weight = 100;}
    { .backend = app5; .weight = 100;}
}

#2

The difference between static and dynamic for Fastly’s Varnish is that for static the hostname is resolved to an IP address at VCL compilation time. Dynamic means that we resolve constantly (whenever the TTL on the DNS record is expired when a probe is performed.)

We have found though, that in a large number of the cases where people did not put .dynamic = true;, they did actually need it.

So we’ve decided to make it mandatory if you use a .host that is not an IP address.

So if the addresses are truly static, just use IPs. If you want a change in address for the hostname to reflect as soon as possible (given TTLs), use a hostname and set .dynamic = true;