Feedback

Chat Icon

Cloud-Native Microservices With Kubernetes - 2nd Edition

A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes

Autoscaling Microservices in Kubernetes: Vertical Scaling
53%

The VPA Recommender: A Statistical Analyzer

The VPA Recommender is the central component that analyzes resource usage data from a historical perspective and generates recommendations for optimal CPU and memory requests for Pods. It uses statistical models to generate recommendations for the optimal resource requests.

The Recommender uses a set of statistical, percentile-based models (rather than machine-learning algorithms). Its goal isn’t to predict usage, but to summarize observed behavior over time and provide recommendations based on that.

Here is what happens under the hood:

  • The Recommender continuously gathers CPU and memory usage metrics from the Metrics API (or Prometheus). These samples are aggregated over time for each container.

  • It applies exponential decay, which means recent data points have more influence than older ones. For example, if the Recommender observes the following time series, starting at t1 (the oldest point) and currently at t5 (the most recent):

Time:         t1    t2    t3    t4    t5
Usage:        10    20    30    40    50

The Recommender applies a smoothing function using a smoothing factor (α) of 0.5 for simplicity:

Smoothed:

t1: 10
t2: 0.5 * 20 + 0.5 * 10 = 15
t3: 0.5 * 30 + 0.5 * 15 = 22.5
t4: 0.5 * 40 + 0.5 * 22.5 = 31.25
t5: 0.5 * 50 + 0.5 * 31.25 = 40.625

This produces the following smoothed series:

```Time: t1 t2 t3 t4 t5
Smoothed: 10 15 22.5 31.25 40.625

In this example, t5 (the newest data point) influences the final value more than any earlier

Cloud-Native Microservices With Kubernetes - 2nd Edition

A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes

Enroll now to unlock all content and receive all future updates for free.