Your question is Basic Load Balancing with Link Weights. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
NVIDIA networking components may expose several links with different capacities. Implement a deterministic load balancer that distributes requests proportionally to integer link weights while avoiding unnecessary bursts on any one link.
Use the smooth weighted round-robin algorithm. For every request, add each link's weight to its running score, select the link with the highest score, subtract the sum of all weights from the selected link's score, and record that link's index. Break ties by choosing the lowest index.
Implement distribute_requests(weights, request_count).
weights is a list of non-negative integers, where weights[i] is the capacity weight of link i.request_count is a non-negative integer.request_count integers. Each integer is the selected link index.0 must never receive requests.def distribute_requests(weights, request_count):