Reference · Snippet · python
Canary traffic split (sketch)
import random
CANARY_PCT = 0.10
def pick_version(request_id: str) -> str:
# sticky: hash request_id for consistent routing
bucket = hash(request_id) % 100
return "v2" if bucket < CANARY_PCT * 100 else "v1"