Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A/B testing - canary with session affinity #88

Merged
merged 11 commits into from
Mar 11, 2019
Merged

A/B testing - canary with session affinity #88

merged 11 commits into from
Mar 11, 2019

Conversation

stefanprodan
Copy link
Member

@stefanprodan stefanprodan commented Mar 8, 2019

Allow A/B testing scenarios where instead of weighted routing the traffic is split between the primary and canary based on HTTP headers or cookies. This is particularly useful for frontend applications where you want to have session affinity.

You can chose from two types of analysis:

Progressive weight

  • canaryAnalysis.maxWeight
  • canaryAnalysis.stepWeight

Match conditions

  • canaryAnalysis.iterations
  • canaryAnalysis.match

Example:

apiVersion: flagger.app/v1alpha3
kind: Canary
spec:
  canaryAnalysis:
    # schedule interval (default 60s)
    interval: 1m
    # total number of iterations
    iterations: 10
    # max number of failed iterations before rollback
    threshold: 2
    # canary match condition
    match:
      - headers:
          # target Safari users
          user-agent:
            regex: "^(?!.*Chrome)(?=.*\bSafari\b).*$"
      - headers:
          # target users based on a cookie content
          cookie:
            regex: "^(.*?;)?(user=test)(;.*)?$"

The above configuration will run an analysis for ten minutes targeting Safari users and those that have a test cookie. You can determine the minimum time that it takes to validate and promote a canary deployment using this formula:

interval * iterations

And the time it takes for a canary to be rollback when the metrics or webhook checks are failing:

interval * threshold 

Fix: #87

Test image: quay.io/stefanprodan/flagger:ab-testing-e80a3d3

Allow A/B testing scenarios where instead of weighted routing the traffic is split between the primary and canary based on HTTP headers or cookies.
@stefanprodan stefanprodan changed the title A/B testing A/B testing - canary with session affinity Mar 8, 2019
@codecov-io
Copy link

codecov-io commented Mar 8, 2019

Codecov Report

Merging #88 into master will increase coverage by 2.77%.
The diff coverage is 75.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #88      +/-   ##
==========================================
+ Coverage    54.8%   57.58%   +2.77%     
==========================================
  Files          13       13              
  Lines        1540     1794     +254     
==========================================
+ Hits          844     1033     +189     
- Misses        556      605      +49     
- Partials      140      156      +16
Impacted Files Coverage Δ
pkg/router/istio.go 87.61% <100%> (+6.52%) ⬆️
pkg/controller/deployer.go 57.92% <44.44%> (-0.79%) ⬇️
pkg/controller/scheduler.go 49.41% <51.61%> (+9.85%) ⬆️
pkg/controller/job.go 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcd5207...12ac96d. Read the comment docs.

@@ -82,6 +82,8 @@ spec:
interval:
type: string
pattern: "^[0-9]+(m|s)"
iterations:
type: number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have to include match field in the crd as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have validation for any of the Istio types (HTTPMatchRequest, HTTPRewrite, HTTPRetry, Headers and CorsPolicy) used in the Canary CRD. This could be addressed in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

@huydinhle
Copy link
Contributor

👍

@stefanprodan stefanprodan merged commit 1cd0c49 into master Mar 11, 2019
@stefanprodan stefanprodan deleted the ab-testing branch March 11, 2019 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants