Can you design an elegant load balancing solution using only a random number generator?
11
20
107
29K
25
Download Video
The total capacity is 100 requests/sec, making this convenient for our random number generator. Server A handles 10% of capacity, B handles 15%, C handles 20%, D handles 25%, and E handles 30%. We can divide the range 1-100 proportionally: If random number is 1-10: Send to Server A If random number is 11-25: Send to Server B If random number is 26-45: Send to Server C If random number is 46-70: Send to Server D If random number is 71-100: Send to Server E This approach ensures each server receives traffic proportional to its capacity. For large-scale systems, you could precompute range mappings and use binary search for efficient routing.