Sticky upstream duration

Hi, I have some questions related to the duration of a sticky session/upstream on a reverse proxy load balancer.

If I use a reverse proxy with lb_policy header XXX, how long does that sticky session last for, is that duration configurable, and where does all of the session related information get stored?

Thanks,
Lee

I believe it is effectively permanent - because Caddy doesn’t actually store session state for this policy, but rather hashes the value of the header to map to an index of upstreams.

That means the same header should always go to the same upstream given a sufficiently similar set of upstreams.

For policies that involve hashing, the highest-random-weight (HRW) algorithm is used to ensure that a client or request with the same hash key is mapped to the same upstream, even if the list of upstreams change.

https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#load-balancing

  • header [field] maps a request header to a sticky upstream, by hashing the header value; if the specified header field is not present, the fallback policy will be used to select an upstream (random by default)

https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#load-balancing

2 Likes

Thank you for clarifying @Whitestrake!