Score:1

Google Cloud: how to auto-scale based on a custom metric

eg flag

So we have a Symfony application running in google cloud.

We would like to auto scale this application based on a number of pending jobs that need to be processed. In order to do this we have written code in the application that every 30 minutes updates a custom metric with the number of jobs that remain to be processed. We can see this metric in the google clouding monitoring explorer updating accordingly.

enter image description here

We are having difficulty with how to use this custom metric to trigger the scale-up and scale down of the pods.

Wojtek_B avatar
jp flag
Can you share some details on have you already tried ?
Wojtek_B avatar
jp flag
It's possible only to [autoscale managed instance group based on custom metrics](https://cloud.google.com/architecture/autoscaling-instance-group-with-custom-stackdrivers-metric) - at least there's a documentation for that. There's nothing about autoscaling a cluster.
Score:0
jp flag

Currently it's impossible to autoscale GKE clusters based of custom metrics.

This feature is available only in case of Managed Instance Groups:

Managed instance groups (MIGs) offer autoscaling capabilities that let you automatically add or delete virtual machine (VM) instances from a MIG based on increases or decreases in load. Autoscaling helps your apps gracefully handle increases in traffic and reduce costs when the need for resources is lower. You define the autoscaling policy and the autoscaler performs automatic scaling based on the measured load and the options you configure.

Autoscaling works by adding more VMs to your MIG when there is more load (scaling out, sometimes referred to as scaling up), and deleting VMs when the need for VMs is lowered (scaling in or down).

You can however reqest such a functionality to be implemented in GKE - raise a new feature request on Issue Tracker and wait for someone to come back to you.

Anshuman Kumar avatar
my flag
Though this is not the same thing as scaling a Cluster, Kubernetes does seems to support autoscaling pods on a custom metric. https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
Anshuman Kumar avatar
my flag
You can pair that up with a ClusterAutoscaler to scale the cluster when the current cluster's resources are being depleted.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.