Professional Cloud DevOps Engineer
Cloud Run offers two main scaling modes: request-driven autoscaling and manual scaling. The default request-driven mode automatically creates or removes container instances based on incoming traffic. Manual scaling locks the service to a fixed number of instances, which provides direct control but ignores any minimum or maximum instance limits set for the service.
To balance performance with cost, you can configure minimum instance settings. This keeps a certain number of containers "warm" to reduce cold-start latency, which is the delay when a new instance starts to serve its first request. However, these idle instances incur costs, creating a trade-off between application responsiveness and your budget. For traffic management during updates, Cloud Run can split traffic between different versions of a service. Under manual scaling, instances are allocated based on each version's traffic share. If the number of active versions exceeds the fixed instance limit, some versions may get zero instances, causing request failures.
Cloud Run's autoscaling can be fine-tuned using several key settings. You can adjust the concurrency setting, which defines how many simultaneous requests a single container instance can handle. You can also set minimum and maximum instance boundaries and choose CPU allocation strategies (like always allocating a CPU or only during request processing) to further control performance and cost.
Autoscaling in Google Kubernetes Engine (GKE) works on three main levels: pods, pod resources, and the cluster's nodes. The Horizontal Pod Autoscaler (HPA) increases or decreases the number of pod replicas in a deployment. It typically uses metrics like average CPU or memory utilization, but can also scale based on load balancer metrics (like requests per second) or custom application metrics you define.
The Vertical Pod Autoscaler (VPA) works differently by adjusting the CPU and memory requests for existing pods. It analyzes a pod's past resource usage and modifies its configuration to better match actual needs, which helps optimize resource use and prevent performance issues. When pods cannot be scheduled because there aren't enough nodes with the right resources, the Cluster Autoscaler adds nodes to the cluster. It can also automatically create specialized node pools, for example when a pod requests a GPU, if no existing node can provide it.
For effective scaling, you often combine HPA, VPA, and the Cluster Autoscaler. The HPA manages the number of pods based on load, the VPA ensures each pod has the right resource size, and the Cluster Autoscaler provides the underlying nodes to host them. You can configure the HPA to use multiple metrics at once, and newer GKE versions enable a Performance HPA profile by default for faster, more responsive scaling that supports large numbers of applications.
Managed Instance Groups (MIGs) provide autoscaling for groups of virtual machines. You configure an autoscaling policy by choosing one or more metrics, setting minimum and maximum instance limits, and tuning behavioral parameters. The autoscaler will recommend a group size based on the signal demanding the largest number of replicas.
You can scale MIGs based on several types of metrics. The most common is CPU utilization, where you set a target average percentage. For workloads with predictable patterns, you can enable predictive autoscaling, which uses historical data to scale out before a traffic spike arrives. Scaling can also be driven by custom metrics (like application latency), Pub/Sub queue depth (based on unacknowledged messages), or other built-in Cloud Monitoring metrics for memory, disk, or network traffic.
To prevent instability and VM thrashing—where instances are rapidly added and removed—you use advanced controls. Scale-in controls add constraints to prevent overly aggressive removal of instances. The stabilization period delays scale-in actions after a scale-out, using the peak load observed during that window to ensure the smaller group can handle bursts. The initialization period (or cool-down period) tells the autoscaler to ignore metric data from brand-new VMs while the application is starting up, so scaling decisions are based on stable performance.
Prepare and test your skills
Prepare and test your skills
The Horizontal Pod Autoscaler (HPA) adjusts the number of pod replicas based on workload, the Vertical Pod Autoscaler (VPA) adjusts CPU and memory requests to properly size each pod, and the Cluster Autoscaler provisions the underlying nodes and node pools needed to host them. Combining these three mechanisms enables multi-dimensional autoscaling across pods, pod resources, and cluster infrastructure.
Managed Instance Groups (MIGs) prevent VM thrashing by using scale-in controls, stabilization periods, and initialization periods. Scale-in controls constrain aggressive instance removal, stabilization periods delay scale-in actions based on peak load during that window, and initialization periods ignore metric data from new virtual machines while applications start up.
Configuring minimum instances keeps container instances warm to reduce cold-start latency for incoming requests, but maintaining those idle instances incurs continuous costs. This setting requires balancing application responsiveness against infrastructure budget.
You are architecting an autoscaling strategy for a latency-critical event processing application deployed on Google Kubernetes Engine (GKE) Standard. The application experiences sudden spikes in message volume from a Google Cloud Pub/Sub subscription and variable memory usage during payload deserialization.
You need to scale the container replicas based on queue depth, optimize container resource sizing without metric contention, and ensure the underlying cluster infrastructure dynamically provisions compute capacity when Pods cannot be scheduled.
Which autoscaling configuration should you implement?