Prepare and test your skills
Prepare and test your skills
Selection and configuration of compute services means matching a workload to the right Google Cloud service based on control, packaging, and scaling needs. Compute is virtualized processing power and memory for running applications, from raw virtual machines where you manage the operating system to managed platforms where Google manages the infrastructure. The right choice balances flexibility against operational effort while supporting availability and scalability.
The Google Cloud compute category covers five service areas that help narrow the choice before picking a specific product. Each area implies different packaging, scaling, and hardware needs for the workload.
Infrastructure as a Service (IaaS) is the compute model that gives you the most control over the environment. In IaaS, you manage the operating system, middleware, and applications, while Google manages virtualization, servers, storage, and networking. IaaS fits teams that need custom kernels, specific drivers, or license-restricted software.
Compute Engine lets you create and run VM and bare metal instances on Google infrastructure with choices for machine series, storage, accelerators, and guest operating systems. Google Cloud VMware Engine (opens in a new tab) lets you migrate and run VMware workloads natively without re-architecting, where Google manages the hardware and VMware platform while you retain control of VMs, guest systems, and applications. Traffic flows from users to your VMs, and your VMs depend on the networks, disks, and images you attach to them.
Managed platforms and services balance control and ease of use by having Google manage infrastructure, operating systems, and runtimes. In this model, you focus on code and jobs instead of servers, which helps teams deploy quickly without deep infrastructure management.
The choice between VMs, containers, and serverless is a trade-off between configuration flexibility and management effort. VMs and containers give more flexibility but require you to manage resources and orchestration, while serverless runs on a preconfigured platform that scales with demand and needs minimal management.
| Service | What you manage | Choose when |
|---|---|---|
| Compute Engine | Guest OS, middleware, applications, machine type, disks, and accelerators | The workload needs full OS control, custom networking, GPUs or TPUs on specific VMs, or lift-and-shift compatibility |
| Google Kubernetes Engine (GKE) | Container workloads, scaling policies, and, in Standard mode, node configuration | The workload is containerized and needs orchestration for deploying, scaling, and managing many services together |
| Cloud Run | Container image and request or event logic; no servers or clusters | The workload is request- or event-driven and should scale automatically without cluster operations |
Exam tip: Choose Compute Engine when OS-level control is required, GKE when container orchestration across services is required, and Cloud Run when you want serverless containers without managing servers or clusters.
Resource optimization and cost management means matching Google Cloud compute capacity to actual workload needs to lower cost without losing performance. In Compute Engine (opens in a new tab), optimization centers on VM size, cheaper provisioning models, scaling VM count with demand, and reducing license fees. Each saving trades cost against risk, so fault tolerance, statefulness, and licensing decide which option is safe.
Matching VM machine types to workloads means selecting virtual CPUs and memory that fit observed use instead of paying for oversized capacity. Machine type recommendations analyze CPU and memory utilization and suggest a predefined machine type that more closely matches real use. For predictable workloads, custom machine types let you provision vCPUs and memory independently, so you pay only for the capacity you need. The recommendation feeds the rightsizing decision before you commit to a custom shape.
Spot VMs are discounted Compute Engine VMs that offer the same machine types, options, and performance as regular VMs at a much lower price. The trade-off is availability: Compute Engine can stop or delete Spot VMs at any time to reclaim zone capacity, so the workload must tolerate interruption. Spot VMs suit fault-tolerant web tiers and batch jobs without high-availability requirements. A managed instance group that uses Spot VMs depends on zone capacity, so it may fail to scale out to its target size during a shortage.
| Provisioning model | Cost | Availability behavior | Machine types and performance |
|---|---|---|---|
| Standard VMs | Higher on-demand price | Not preempted to reclaim capacity | Full choice of machine types, options, and performance |
| Spot VMs | Significantly lower than standard VMs | Can be stopped or deleted at any time to reclaim capacity | Same machine types, options, and performance as standard VMs |
Autoscaling in stateless managed instance groups controls cost by adding VMs when traffic rises and removing VMs when demand falls. The autoscaler watches load, traffic flows from the load balancer to the group members, and then the group creates VMs in the zone to handle increases and deletes VMs when need is low. Stateful managed instance groups (opens in a new tab) preserve disks and per-instance state, so they cannot be autoscaled because deleting an instance would discard preserved data. Choose a stateless design when the workload must scale in and out with demand.
Exam tip: Use Spot VMs only for fault-tolerant workloads that can tolerate preemption, and use autoscaling only with stateless MIGs because stateful MIGs cannot be autoscaled.
Third-party licensing optimization reduces operating system and database fees when migrating to Compute Engine. Bring your own licenses (BYOL) lets you reuse existing licenses instead of paying for a premium image; for example, a custom Windows BYOL image means you pay only for VM infrastructure and not an added Windows fee. With BYOL, custom machine types let you provision only the CPU cores you need, which limits per-core cost, and disabling simultaneous multithreading (SMT) reduces vCPUs per core from 2 to 1. For databases, a self-managed database such as Microsoft SQL Server on Compute Engine requires separate software license costs, while a managed service such as Cloud SQL (opens in a new tab) includes database license costs in the service charge.
Reservations provide assured Compute Engine capacity in a specific zone for a set number of VMs of a chosen machine type. A reservation holds capacity before demand arrives, so VMs can be created even when the zone is constrained, and the reservation can apply to one project or be shared across multiple projects. Reservations are the opposite of Spot VMs: Spot VMs offer the deepest discount with no capacity guarantee, while reservations prioritize availability over discount. Choose reservations when workloads cannot wait for capacity or cannot tolerate preemption.
Automated provisioning and scalability strategies use repeatable definitions and managed groups to deploy identical VMs and grow capacity without manual steps. In Google Cloud, instance templates (opens in a new tab) define what to deploy, managed instance groups deploy and manage VMs as a single entity, and infrastructure-as-code tools store those definitions in versioned code. Together with load balancing and autoscaling, this workflow delivers consistent deployment and elastic scaling across zones and regions.
Instance templates are global Compute Engine resources that define the configuration for every VM in a group, including machine type, boot-disk image, network, and startup script. A managed instance group depends on its instance template, so traffic flows from the load balancer to the group and the group creates VMs from the template whenever capacity is needed. Although templates are global, they can reference zonal or regional resources, so templates should reference regional resources when possible to stay usable in every zone. To keep deployments identical, use custom OS images in a custom image family that always points to the newest image, patch those images regularly, and pin exact software versions in startup scripts so different VMs do not install different software.
Regional managed instance groups (MIGs) (opens in a new tab) automatically provision VMs across multiple zones in a region based on demand and available capacity. Individual VMs are zonal resources that become unavailable during a zonal outage, so a regional MIG keeps the application available by spreading VMs so one zone or host failure does not stop the service. Regional MIGs use a target distribution shape to control that spread, and the EVEN shape is recommended because it keeps VM counts within one unit across zones. To improve robustness, apply a spread placement policy so VMs in each zone land on different physical hosts, and create reservations to assure capacity for future scale-out.
An automated provisioning workflow follows an ordered sequence:
Autoscaling in managed instance groups (MIGs) (opens in a new tab) dynamically adds VMs when demand rises and removes VMs when demand falls, which maintains performance while avoiding idle infrastructure. The autoscaler watches target utilization metrics and scales between a configured minimum and maximum size, so the MIG depends on Cloud Monitoring metrics to decide when to scale. Horizontal scaling, which adds more identical VMs, is preferred for cloud-first applications over vertical scaling, which enlarges individual VMs, because horizontal scaling tolerates single-instance failures and handles variable load better. Effective policies combine reactive scaling for spikes with scheduled scaling for predictable patterns, use signals beyond CPU such as latency or queue depth, and prevent flapping from frequent scale-in and scale-out actions. For horizontal scaling to work, applications should be stateless by storing session state outside the VM, such as in Memorystore for Redis, so any VM can serve any user.
| MIG type | Autoscaling support | State handling |
|---|---|---|
| Stateless MIG | Supports reactive and schedule-based autoscaling on utilization metrics | Treats VMs as identical and replaceable, with no preserved disks or metadata |
| Stateful MIG | Cannot be autoscaled | Preserves stateful disks and configurations on each VM across restarts and updates |
Exam tip: Stateless MIGs support autoscaling, while stateful MIGs cannot be autoscaled — choose stateless MIGs when elastic scaling is required.
Infrastructure as code (IaC) treats provisioning logic like application code by storing templates and group definitions in source control for versioning, audit, and testing. Infrastructure Manager (opens in a new tab) declaratively provisions Google Cloud resources, while Config Connector (opens in a new tab) manages Google Cloud resources as Kubernetes objects, and both integrate with CI/CD pipelines for validation and rollout. This approach supports immutable infrastructure, where deployed VMs are never modified in place but are fully redeployed from an updated template after changes are tested.
To update a running MIG, create a new instance template with the new machine type or image and apply it with an automatic or selective update. Automatic updates roll the change across VMs without manual intervention, while selective updates give operators control over which VMs are rebuilt and when.
Compute Engine fits workloads needing full operating system control, Google Kubernetes Engine (GKE) fits containerized workloads needing orchestration, and Cloud Run fits request- or event-driven workloads needing automatic scaling without cluster operations. Compute Engine is chosen when the workload needs full OS control, custom networking, GPUs or TPUs on specific VMs, or lift-and-shift compatibility, GKE is chosen when containerized services need deploying, scaling, and managing together, and Cloud Run is chosen when containers should scale automatically without managing servers or clusters.
Spot VMs offer the same machine types, options, and performance as standard VMs at a significantly lower price but can be stopped or deleted at any time to reclaim zone capacity. Standard VMs charge a higher on-demand price and are not preempted to reclaim capacity, so Spot VMs suit only fault-tolerant workloads such as fault-tolerant web tiers and batch jobs without high-availability requirements.
Stateful managed instance groups (MIGs) preserve disks and per-instance state, so deleting an instance would discard preserved data. Stateless managed instance groups (MIGs) treat virtual machines as identical and replaceable with no preserved disks or metadata, so only stateless managed instance groups (MIGs) support reactive and schedule-based autoscaling to add and remove virtual machines with demand.
Reservations provide assured Compute Engine capacity in a specific zone for a set number of virtual machines of a chosen machine type and can apply to one project or be shared across multiple projects. Reservations prioritize availability over discount, which is the opposite trade-off from Spot VMs that offer the deepest discount with no capacity guarantee and can be stopped or deleted at any time to reclaim zone capacity.
An enterprise is implementing an automated provisioning and elasticity strategy using Terraform to deploy a mission-critical, stateless serving workload across multiple Google Cloud regions. The deployment must satisfy the following architectural requirements:
Which configuration should you define in your Terraform templates to achieve this architecture?
Define separate zonal google_compute_instance_template resources per zone, create individual zonal google_compute_instance_group_manager resources in each zone, and attach individual google_compute_autoscaler resources.
Define a global google_compute_instance_template, deploy a google_compute_region_instance_group_manager in each region configured with an ANY_SINGLE_ZONE distribution shape, and attach a google_compute_region_autoscaler.
Define a global google_compute_instance_template, deploy a stateful google_compute_region_instance_group_manager in each region configured with stateful disks, and attach a google_compute_region_autoscaler to manage scaling.
Define a global google_compute_instance_template, deploy a google_compute_region_instance_group_manager in each region with an EVEN target distribution shape and an application health check autohealing policy, and attach a google_compute_region_autoscaler.
Last updated