flagger icon indicating copy to clipboard operation
flagger copied to clipboard

sessionAffinity stickiness communication

Open takezyou opened this issue 2 years ago • 3 comments

Describe the feature

I would like to solve one problem with sessionAffinity functionality.

Canary status:

  • Stop canary releases at a certain percentage for a certain period of time.
  • primary weighs 50% and canary weighs 50%.

If sessionAffinity is enabled in this state, a cookie will be given when traffic flows to canary, and canary traffic will increase. Therefore, the traffic will gradually stop flowing to the primary.

I would like to achieve stickiness communication: once traffic flows to primary, it will continue to flow to primary for a certain period of time, and once traffic flows to canary, it will continue to flow to canary for a certain period of time.

This idea is based on the Akamai ALB and AWS ALB sticky setup.

ref.

  • https://techdocs.akamai.com/cloudlets/docs/config-app-load-balancer-beh
  • https://docs.aws.amazon.com/elasticloadbalancing/latest/application/sticky-sessions.html

Proposed solution

I am wondering if it is possible to achieve stickiness communication by giving a cookie to the primary as well, using the following method.

sessionAffinity:
  primary:    
    cookieName: flagger-primary
    maxAge: 86400
  canary:
    cookieName: flagger-canary
    maxAge: 86400
spec:
  hosts: []
  http:
  - match:
    - headers:
        Cookie:
          regex: .*flagger-canary.*kkuchhkCku.*
    name: sticky-route-canary
    route:
    - destination:
        host: primary
      weight: 0
    - destination:
        host: canary
      weight: 100
    timeout: 3.5s
  - match:
    - headers:
        Cookie:
          regex: .*flagger-primary.*fdakljdfa.*
    name: sticky-route-primary
    route:
    - destination:
        host: primary
      weight: 100
    - destination:
        host: canary
      weight: 0
    timeout: 3.5s
  - route:
    - destination:
        host: primary
      headers:
        response:
          add:
            Set-Cookie: flagger-primary=fdakljdfa; Max-Age=86400
      weight: 50
    - destination:
        host: canary
      headers:
        response:
          add:
            Set-Cookie: flagger-canary=kkuchhkCku; Max-Age=86400
      weight: 50

I would like to know if you have any other good solutions.

takezyou avatar Oct 06 '23 15:10 takezyou

This is not a problem with the session affinity functionality, it was designed this way on purpose. The idea is to prevent users from switching back to the primary after they have been directed to the canary. We don't want to keep users stuck to the primary.

aryan9600 avatar Oct 17 '23 08:10 aryan9600

@aryan9600 Thanks for your reply. I understood that it is an intentional design of session affinity. I would like to keep them in primary as well for the use case I have, would you consider such a feature?

takezyou avatar Oct 23 '23 01:10 takezyou