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

意见

使用Amazon ELB Application Load Balancer并使用Sticky Sessions时,负载均衡器会在第一个请求中插入名为AWSALB的cookie.要让下一个请求粘贴到同一目标节点(EC2实例),cookie应该包含在该请求中.这样做时,负载均衡器似乎在对第二个请求的响应中插入了不同的cookie值.在第3个请求中包含此新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.

转载注明原文:amazon-web-services – 是否需要最新的AWSALB cookie? (AWS ELB应用程序负载均衡器) - 代码日志