简体   繁体   English

基于活动会话配置 Kube.netes HPA

[英]Configure Kubernetes HPA based on active sessions

Is there a way to configure Kube.netes Horizontal Pod Autoscaler based on the sessions which the pod has?有没有办法根据 Pod 的会话配置 Kube.netes Horizontal Pod Autoscaler? For example, we have an application which stores user sessions.例如,我们有一个存储用户会话的应用程序。 I have configured HPA to trigger based on CPU.我已将 HPA 配置为基于 CPU 触发。 But the issue is when the HPA scales down, the active session also gets disrupted since the pod is deleted.但问题是,当 HPA 缩减时,活动的 session 也会因为 pod 被删除而中断。 Is there a custom metric or a way we can configure this?是否有自定义指标或我们可以配置它的方法?

HPA can make scaling decisions based on custom or externally provided metrics and works automatically after initial configuration. HPA 可以根据自定义或外部提供的指标做出扩展决策,并在初始配置后自动运行。 All you need to do is define the MIN and MAX number of replicas.您需要做的就是定义副本的 MIN 和 MAX 数量。

Once configured, the Horizontal Pod Autoscaler controller is in charge of checking the metrics and then scaling your replicas up or down accordingly.配置完成后,Horizontal Pod Autoscaler controller 负责检查指标,然后相应地扩大或缩小副本。 By default, HPA checks metrics every 15 seconds.默认情况下,HPA 每 15 秒检查一次指标。

To check metrics, HPA depends on another Kube.netes resource known as the Metrics Server.为了检查指标,HPA 依赖于另一个称为指标服务器的 Kube.netes 资源。 The Metrics Server provides standard resource usage measurement data by capturing data from “kube.netes.summary_api” such as CPU and memory usage for nodes and pods. Metrics Server 通过从“kube.netes.summary_api”获取数据来提供标准的资源使用测量数据,例如节点和 Pod 的 CPU 和 memory 使用情况。 It can also provide access to custom metrics ( that can be collected from an external source ) like the number of active sessions on a load balancer indicating traffic volume.它还可以提供对自定义指标(可以从外部来源收集)的访问,例如负载均衡器上指示流量的活动会话数。

Try Session affinity which provides a best-effort attempt to send requests from a particular client to the same backend for as long as the backend is healthy and has the capacity, according to the configured balancing mode.根据配置的平衡模式,尝试Session 亲和力,只要后端健康且具有容量,它就会尽最大努力尝试将请求从特定客户端发送到同一后端。

When you use session affinity, we recommend the RATE balancing mode rather than UTILIZATION.当您使用 session affinity 时,我们建议使用 RATE 平衡模式而不是 UTILIZATION。 Session affinity works best if you set the balancing mode to requests per second (RPS). Session 如果将平衡模式设置为每秒请求数 (RPS),亲和力效果最佳。

Please go throughKube.netes HPA for more information.请通过Kube.netes HPA go了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM