Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-349

Canary Traffic Split

Problem

Split incoming traffic between a canary and the stable model. The canary receives int(total_requests * canary_percent / 100) requests and the remainder goes to stable. Return [canary, stable]; a non-positive total returns [0, 0] and a non-positive percent sends everything to stable.

Hint

Starting small limits the blast radius if the new model misbehaves.

Test cases

case 1
in: [1000,10]
expected: [100,900]
case 2
in: [333,10]
expected: [33,300]
case 3
in: [50,0]
expected: [0,50]
case 4
in: [0,10]
expected: [0,0]
case 5
in: [50,100]
expected: [50,0]
Starter codePython
def canary_split(total_requests, canary_percent):
    # Returns [canary, stable]
    # Your code here
    pass

5 test cases · run your code against them in the editor