The proxy.pac system works really well and you can do both load balancing and failover with it. It's just JavaScript so it can be easily bent to your will 


What you need to do is configure two (or more proxies) then use a Math.random function to randomly give out different details to the browsers. The browsers themselves then provide the failover from that configuration, as they'll detect if one proxy stops responding and automatically start using the second.


To give you a rough idea, you can do things like this in the proxy.pac :


if (Math.random() < 0.5) {   

        return "PROXY proxy1.domain.local:8080; PROXY proxy2.domain.local:8080";

    } else {

        return "PROXY proxy2.domain.local:8080; PROXY proxy1.domain.local:8080";

    }

}


This would result in 50% of the users using proxy1, with proxy2 as a failover and 50% using it the other way around. There's no limit to the number of proxies you can return and you can adjust this so you can split the proxies 4 ways instead of 2. For example:


var rnd = Math.random();

if (rnd > 0.75 ) {   

        return "PROXY proxy1:8080; PROXY proxy2:8080; PROXY proxy3:8080; PROXY proxy4:8080";

    } else if (rnd > 0.5) {

        return "PROXY proxy2:8080; PROXY proxy3:8080; PROXY proxy4:8080; PROXY proxy1:8080";

    } else if (rnd > 0.25) {

        return "PROXY proxy3:8080; PROXY proxy4:8080; PROXY proxy1:8080; PROXY proxy2:8080";

    } else {

        return "PROXY proxy4:8080; PROXY proxy1:8080; PROXY proxy2:8080; PROXY proxy3:8080";

    }

}


You can also set other variables in the load balancer to do things like splitting traffic by IP segment. See example below (example of the pac file also attached:


//Send to proxy

if(Math.random() < 0.5 && isInNet(myip, "172.16.0.0", "255.255.0.0")

|| isInNet(myip, "172.17.0.0", "255.255.0.0"))

  {

     return proxy_censornet01 ; proxy_censornet02;

  }

  else if (Math.random() > 0.5 && isInNet(myip, "172.16.0.0", "255.255.0.0")

|| isInNet(myip, "172.17.0.0", "255.255.0.0"))

  {

     return proxy_censornet02 ; proxy_censornet01;      

  }    

else 

  {

    return proxy_no;

    }

}


 Here's a good basic example of proxy.pac files: https://findproxyforurl.com/example-pac-file/