Diego
Diego

Reputation: 793

Is there an HPA configuration that could autoscale based on previous CPU usage?

We currently have a GKE environemt with several HPAs for different deployments. All of them work just fine out-of-the-box, but sometimes our users still experience some delay during peak hours.

Usually this delay is the time it takes the new instances to start and become ready.

What I'd like is a way to have an HPA that could predict usage and scale eagerly before it is needed.

The simplest implementation I could think of is just an HPA that could take the average usage of previous days and in advance (say 10 minutos earliers) scale up or down based on the historic usage for the current time-frame.

Is there anything like that in vanilla k8s or GKE? I was unable to find anything like that in GCP's docs.

Upvotes: 0

Views: 62

Answers (1)

Hussein Awala
Hussein Awala

Reputation: 5088

If you want to scale your applications based on events/custom metrics, you can use KEDA (Kubernetes-based Event Driven Autoscaler) which support scaling based on GCP Stackdriver, Datadog or Promtheus metrics (and many other scalers).

What you need to do is creating some queries to get the CPU usage at the moment: CURRENT_TIMESTAMP - 23H50M (or the aggregated value for the last week), then defining some thresholds to scale up/down your application.

If you have trouble doing this with your monitoring tool, you can create a custom metrics API that queries the monitoring API and aggregate the values (with the time shift) before sending it to the metrics-api scaler.

Upvotes: 1

Related Questions