[算法]流量加权负载控制
public class ModRoutingTest {
public static void main(String[] args) {
//a渠道调用量
int a = 0;
//b渠道调用量
int b = 0;
//切量比 a:all
int rate = 5;
//样本数
int sample = 1000000;
for (int i = 0; i < sample; i++) {
Random random = new Random();
int rand = random.nextInt(1000000000);
if (rand % 10 < rate) {
a++;
} else {
b++;
}
}
System.out.format("hit->a : %s , hit->b : %s", a, b);
//hit->a : 499681 , hit->b : 500319
}
}