plugins

BareProxy A-B and Canary Splits Plugin: Sending a Share of Traffic to a New Version

Status: built, number 7 of 21 in BareProxy’s build order, and out in BareProxy 0.9.0 as splits.wasm on the releases page. Its manual is the README in the code repository.

A new version of an app is safest when it meets real traffic a little at a time. Send 5 percent of visitors to it, watch the errors, then 25, then everyone. The same mechanism runs A/B tests: half the visitors see one design, half the other, and each visitor keeps seeing the same one.

What It Does

  • Splits by share. Each new visitor gets a variant by the shares in the plugin’s config, such as 95 and 5. Over 100,000 test visitors, a 5 percent share landed within half a point of 5.
  • Keeps visitors where they are. The variant is stored in a cookie, so a visitor doesn’t bounce between versions from one click to the next.
  • Sends people on purpose. The office by address, testers by a header or a cookie, and anyone with a preview link: ?preview=canary puts a visitor on the canary for the rest of the visit.
  • Marks the request. The plugin puts the variant in a request header, X-Variant: canary, which the app can log. A variant header a visitor sends is replaced, so nobody picks their own.
  • Drains in one step. Set a variant’s share to 0 and its visitors are assigned again on their next request, cookie or not.

Routing Stays in the Config

The plugin chooses a variant; BareProxy’s own rules choose the pool. That keeps every routing decision where plan and explain can see it:

plugin split /etc/bareproxy/plugins/splits.wasm
  config /etc/bareproxy/plugins/split.conf

site example.com
  use split
  route /* header X-Variant=canary -> app-next
  route /* -> app

And the plugin’s own config:

# split.conf
variant stable 95
variant canary 5
force canary address 10.0.0.0/8
force canary query preview=canary

Moving from 5 to 25 percent is a change to that file, and plan lists it as a change before it goes live. Rolling back a bad canary is bareproxy rollback.

Seeing the Split

why on any request shows which variant it got and why: assigned by share, kept by the cookie, or forced by a line of the config. status counts the requests each variant gets, so the real split is there to read.

A Possible Next Step

BareProxy’s earlier plan had a module called Guard, which would watch errors after a change and roll back by itself if they jumped. A canary is where that matters most. With splits in place, a guard that compares the canary’s error rate with the main version’s is the natural next plugin.

The whole program is on the plugins page.