Intrigued by the art of cloud architecture? Discover how to design, develop, and manage robust, secure, scalable, and dynamic solutions on Google Cloud as you prepare for the Professional Cloud Architect exam!
Google Cloud offers two main provisioning models for virtual machines: Standard VMs and Spot VMs. Standard VMs provide reliable, always-on compute and let you control when an instance stops or starts. Spot VMs, on the other hand, use excess Google Cloud capacity and offer a 60% to 91% discount compared to standard pricing. However, Spot VMs are subject to preemption—Google can reclaim the resources at any time. Because of this volatility, Spot VMs do not come with a Service Level Agreement (SLA) or standard uptime guarantees.
Choosing the right model depends on balancing budget with performance needs. Standard VMs are best for critical services that must run 24/7, such as web servers or primary databases. Spot VMs are ideal for fault-tolerant tasks that can pause and resume, including:
Using the right instance type for each job ensures you do not pay full price for non-critical background tasks.
A common strategy is to use Managed Instance Groups (MIGs) to combine both standard and spot instances in a single environment. If a Spot VM is preempted, the MIG automatically attempts to recreate it when capacity becomes available again. This hybrid approach maintains a minimum level of service while scaling up cheaply when possible. Beyond basic provisioning, you can also use Committed Use Discounts (CUDs) for predictable workloads and the Recommender tool to suggest optimal machine types. Combining these financial strategies with a mix of spot and standard instances creates a highly efficient cloud architecture.
Standard VMs are regular instances that stay running until you stop them, providing reliable performance. Spot VMs are created from excess capacity and offer a significant discount, but Google can reclaim them at any time through preemption. The choice between them depends on how your workload handles interruptions.
Standard VMs are best for mission-critical applications that require constant uptime and high availability. Spot VMs are ideal for fault-tolerant workloads where a sudden stop won't cause total failure. Common examples for Spot usage include:
When Google needs capacity back, it stops or deletes your Spot instance based on the chosen termination action. To handle this volatility, you should use shutdown scripts to save your application's progress before the VM turns off. This ensures the job can pick up where it left off instead of starting over. You can also combine both VM types in a single cluster to balance cost and progress.
You can manage these instances using Managed Instance Groups (MIGs) and Instance Templates. A MIG will automatically try to recreate your Spot VMs once resources become available again. Spot VMs do not support live migration or automatic restart during host maintenance events, so they are not covered by SLAs and require extra planning for reliability. Setting up these models is done by selecting the provisioning model during instance creation using the Google Cloud console, the gcloud CLI, or the API. Once running, you can monitor the scheduling properties to verify the model and current termination settings.
Spot VMs are cost-effective but subject to preemption—Google can reclaim the resources at any time. This provisioning model is ideal for fault-tolerant tasks like batch processing where a sudden shutdown won't cause the entire project to fail. To manage sudden shutdowns, you should use shutdown scripts to save your application's progress. When a VM is marked for preemption, Google sends a termination signal, giving the instance a 30-second window to finish tasks. During this time, the script can perform the following actions:
Using Managed Instance Groups (MIGs) is a key strategy for maintaining application availability during volatility events. A MIG will automatically attempt to recreate any Spot VMs that have been preempted as soon as capacity becomes available again. This ensures your cluster eventually returns to its target size without manual intervention.
For better workload resilience, experts recommend combining standard VMs with Spot VMs within your infrastructure. This hybrid approach ensures that at least some of your compute power is stable, while the Spot VMs handle the heavy lifting at a lower cost. Additionally, distributing instances across multiple zones or regions helps protect your system from local outages or resource shortages.
Finally, it is important to monitor your environment to understand how often preemption occurs. You can use Cloud Logging to search for the compute.instances.preempted event to track which instances were stopped. By evaluating these logs, you can determine if your current compute volatility configuration is meeting your performance and budget goals.
Prepare and test your skills
Prepare and test your skills
Standard VMs provide reliable, always-on compute with uptime guarantees and Service Level Agreements (SLAs), whereas Spot VMs utilize excess Google Cloud capacity at a 60% to 91% discount. In exchange for lower pricing, Spot VMs are subject to preemption at any time and do not support live migration, automatic restart during host maintenance, or SLA coverage.
Shutdown scripts execute during the 30-second termination window provided after Google marks a Spot VM for preemption. During this period, the script can save progress checkpoints to a Cloud Storage bucket, cleanly close active network connections, and log the instance state for future recovery.
Managed Instance Groups (MIGs) automatically attempt to recreate preempted Spot VMs once resources become available, returning the cluster to its target size without manual intervention. MIGs can also combine standard and spot instances in a single environment to maintain a baseline level of service while scaling cost-effectively.
Configure VM instances to reject ACPI shutdown signals, and use an automated Cloud Function to invoke compute.instances.resume on preempted instances.
Implement a shutdown script or monitor the metadata server for preemption notices to save checkpoint data, and configure the regional Managed Instance Group to automatically recreate preempted instances across zones.
Enable deletion protection on the VM instances, and configure a startup script to capture checkpoint data when receiving a diagnostic interrupt signal.
Deploy the instances in a single-zone unmanaged instance group, and set the instance scheduling policy to live migrate during host maintenance events.
An analytics firm processes asynchronous, fault-tolerant batch workloads on Google Cloud. To minimize infrastructure costs, the engineering team decides to deploy the worker nodes on Spot Virtual Machines (VMs) managed by a regional Managed Instance Group (MIG).
The architecture must satisfy the following operational requirements:
Which strategy should you implement to handle preemption and maintain workload resilience?