plugins

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

Status: planned, number 7 of 21 in BareProxy’s build order. The plugins are built easiest first, and this one is about a day of coding: a cookie and a header; the core’s routes do the rest. It comes after the Request signing plugin. This post describes what it will do, and it will be updated as it is built.

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 Will Do

  • Split by percentage. Each new visitor is assigned a variant by the shares in the plugin’s config, such as 95 and 5.
  • Keep visitors where they are. The assignment is stored in a cookie, so a visitor doesn’t bounce between versions from one click to the next.
  • Split by rule. Staff by address or header, a beta-tester cookie, or a query parameter can be sent to a variant on purpose.
  • Mark the request. The plugin puts the variant in a request header, such as X-Variant: canary, which the app can log.

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.json

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

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

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.

why on any request will show which variant it got and why.

The whole program is on the plugins page.