是否需要最新的 AWSALB cookie? (AWS ELB 应用程序负载均衡器)

Is the most recent AWSALB cookie required? (AWS ELB Application Load Balancer)

观察

使用 Amazon ELB Application Load Balancer 并使用 Sticky Sessions 时,负载均衡器会在第一个请求中插入一个名为 AWSALB 的 cookie。为了让下一个请求坚持同一个目标节点(EC2 实例),cookie 应该包含在该请求中。这样做时,负载均衡器似乎在对第二个请求的响应中插入了不同的 cookie 值。当在第三个请求中包含这个新的 cookie 值时,我们会在响应中得到一个新的 cookie 值。等等……

(这与 Sticky Sessions works with the Classic Load Balancer 的方式不同,其中 cookie 被命名为 AWSELB 并保留其值直到被客户端或负载平衡器丢弃。)

AWSALB cookie 一直更改值的原因似乎是(如 docs 所述):

The name of the cookie is AWSALB. The contents of these cookies are encrypted using a rotating key. You cannot decrypt or modify load balancer-generated cookies.

所以即使 cookie 的内容可能相同,我们也无法分辨。

问题

问题是对负载均衡器的请求是否必须总是包括最近收到的AWSALB cookie 值,或者是否可以发送一些以前收到的值值(当然来自同一个粘性会话)。

如果这是一项要求,AWS ELB 应用程序负载均衡器将无法为执行多个并行请求的客户端提供服务(在收到第一个 AWSALB cookie 之后),而只能为执行所有请求的客户端提供服务顺序方式(一次一个)。

任何人都可以阐明这一点吗?

在这里等待回复后,我向亚马逊提出了支持案例并得到了回复:

I understand that you would like to confirm if it is required to provide the latest stickiness cookie for every request.

You are right in noting that the behaviour is different between CLB and ALB. Due to the different functionality of Application Load Balancer to direct traffic to multiple Target Groups, each having its own stickiness, ALB encrypts the information needed to direct traffic and provides new cookie on each request. This ensures that different times for different groups are always respected correctly.

Clients can always obtain the latest cookie, as internally the information would ensure correct routing to the same target. If you want to reuse single cookie it is also possible, ALB will respect it and correctly route the traffic as per the stickiness in the cookie. I would not recommend using the same cookie for periods longer than 60 seconds though. This is to ensure that in case of target becoming unavailable you can acquire new cookie with new stickiness information that would route you to new target.