Kubernetes offers two default paths for scaling Node.js workloads, and both have structural limitations. The Horizontal Pod Autoscaler scales on CPU utilization, which does not directly measure event loop saturation: a Node.js pod can queue requests and miss latency SLOs while CPU reports moderate usage. KEDA extends HPA with richer triggers, including event-loop metrics, but inherits the same reactive control loop, detecting overload only after it has begun. By the time new pods start and absorb traffic, the system may already be degraded. Lowering thresholds shifts the operating point but does not change the dynamic: the scaler still reacts to a value it has already crossed, at the cost of permanent over-provisioning. We propose a predictive scaling algorithm that forecasts where load will be by the time new capacity is ready and scales proactively based on that forecast. Per-instance metrics are corrupted by the scaler's own actions: adding an instance redistributes load and changes every metric, even if external traffic is unchanged. We observe that operating on a cluster-wide aggregate that is approximately invariant under scaling eliminates this feedback loop, producing a stable signal suitable for short-term extrapolation. We define a metric model (a set of three functions that encode how a specific metric relates to scaling) and a five-stage pipeline that transforms raw, irregularly-timed, partial metric data into a clean prediction signal. In benchmarks against HPA and KEDA under steady ramp and sudden spike, the algorithm keeps per-instance load near the target threshold throughout. Under the steady ramp, median latency is 26ms, compared to 154ms for KEDA and 522ms for HPA.
翻译:Kubernetes为Node.js工作负载提供了两种默认扩缩路径,但两者均存在结构性局限。水平Pod自动扩缩器基于CPU利用率进行扩缩,但CPU利用率并不能直接反映事件循环饱和度:在CPU显示中等使用率时,Node.js Pod可能已出现请求排队并违反延迟服务等级协议。KEDA通过引入事件循环指标等更丰富的触发信号扩展了HPA,但继承了相同的反应式控制循环——只有在过载发生后才能检测到。当新Pod启动并吸收流量时,系统性能可能已经恶化。降低阈值虽能改变运行点,却无法改变动态特性:扩缩器仍会对已越界的数值做出反应,且需以永久性过度预置为代价。我们提出一种预测性扩缩算法,该算法可预测新容量就绪时的负载水平,并基于该预测主动进行扩缩。实例级指标会被扩缩器自身行为所干扰:即使外部流量不变,增加实例也会重新分配负载并改变所有指标。我们观察到,采用集群范围且近似不随扩缩变化的聚合指标,可消除此反馈回路,产生适合短期外推的稳定信号。我们定义了一个指标模型(三组编码特定指标与扩缩关系的函数)和一个五阶段流水线,可将原始、非定时、不完整的指标数据转化为清晰的预测信号。在与HPA及KEDA的基准测试中(涵盖稳定递增流量和突发流量场景),该算法始终将实例级负载维持在目标阈值附近。在稳定递增场景下,中位数延迟为26毫秒,而KEDA为154毫秒,HPA为522毫秒。