Optimization of load balancing in anonymous dynamical networks with application to Tor