Skip to content

Commit e972348

Browse files
committed
opt(lb): optimize the performance of weighted_random load balancer
1 parent da94cd3 commit e972348

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

volo/src/loadbalance/random.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ fn pick_one(
1919
if sum_of_weight == 0 {
2020
return None;
2121
}
22+
if instances.len() == 0 {
23+
return None;
24+
}
2225
let weight = rand::rng().random_range(0..sum_of_weight);
2326
let index = prefix_sum_of_weights
2427
.binary_search(&weight)

0 commit comments

Comments
 (0)