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

标签 amazon-web-services elastic-load-balancer sticky-session

观察结果

当使用Amazon ELB应用程序负载均衡器并使用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的最新接收值,或者是否可以发送某些先前接收到的值(当然,是从同一粘性 session 发送的)。

如果这是必需的,则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应用程序负载均衡器),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49197688/

相关文章:

linux - 如何在 AWS ec2 实例中为不同的浏览器选项卡/程序使用多个 IP?

json - 使用 aws cli 枚举 aws 标签

smtp - 如何正确设置 DNS SPF 记录?

php - 负载均衡器后面的 SilverStripe

tomcat - WebLogic 的 <session-param> 配置元素实际上做了什么?

amazon-web-services - 调用 CreateChangeSet 操作时出现 ValidationError:模板错误:Fn::GetAtt 的实例引用未定义的资源”

amazon-web-services - 创建AWS Application Load Balancer规则,该规则可修剪请求的前缀,而无需使用其他反向代理,例如nginx,httpd

wordpress - 从 Load Balancer 后面的 AWS certificate Manager 使用 SSL 设置 wordpress 网站

kubernetes - 如何使用容器为具有(长期)粘性 session 的应用程序进行零停机滚动更新

ruby - 除了 ClientIP 之外,还有其他方法可以为 kubernetes 中的 sessionAffinity 提供自定义值吗?