Load balancing varnish 4

Since I had to google a lot to find this here a simple config for loadbalancing in varnish 4

vcl 4.0;
 
import std;
import directors;
 
backend server1 {
    .host = "ip/hostname";
}
backend server2 {
    .host = "ip/hostname";
}
 
sub vcl_init {
	new vdir = directors.round_robin();
	vdir.add_backend(server1);
	vdir.add_backend(server2);
}
 
sub vcl_recv {
    set req.backend_hint = vdir.backend();
}

Comments are closed.