Power of two choices

Shipped
alias p2c

Sample two candidates, pick the less loaded. Near-optimal and O(1).

Example

How Power of two choices decides — the pool is evaluated and the winner is assigned. Each strategy selects differently.

type == "lead"selectedTriggerNew LeadWebhookPower of twoPower of two choicesStrategyae-westload 2 · sampledae-eastload 7 · sampledAssigned
Show the code
// Power of two choices selects from the pool and assigns.
engine.Route(ductor.Route{
Match: `routable.type == "lead"`,
Strategy: "power_of_two_choices",
Pool: "sales-team",
})
 
// Durable, observable, exactly-once.
decision, err := engine.Dispatch(ctx, routable)

How it works

Envoy's default load balancer. Picks two recipients at random and routes to the one with lower load — near-optimal balancing without the herding of global least-loaded, at constant cost.

Stateful