Availability policy for Compute Engine
Availability policy for Compute Engine determines how your virtual machine instances behave during maintenance events and unexpected failures. Understanding these policies is crucial for designing resilient cloud solutions. **On Host Maintenance** This setting controls what happens when Google performs maintenance on the physical host running your VM. You have two options: 1. **Migrate (default)**: Google live migrates your VM to another host, keeping it running with minimal disruption. This is recommended for most workloads as it maintains availability. 2. **Terminate**: The VM stops during maintenance and restarts afterward. This suits workloads that cannot tolerate live migration or require specific hardware configurations. **Automatic Restart** This boolean setting determines whether your VM automatically restarts after a crash or maintenance-related termination. When enabled (default), Compute Engine attempts to restart your instance if it terminates due to non-user-initiated reasons. Disable this for batch processing jobs or instances managed by external orchestration tools. **Preemptibility and Spot VMs** Preemptible VMs and Spot VMs are significantly cheaper (60-91% discount) but can be terminated by Google with 30 seconds notice when capacity is needed. These instances always terminate during maintenance events and have a maximum runtime of 24 hours for preemptible VMs. Spot VMs have no maximum runtime but share similar preemption characteristics. **Best Practices** - Use migration for production workloads requiring high availability - Enable automatic restart for critical services - Implement instance groups with autohealing for fault tolerance - Use regional managed instance groups to spread instances across zones - Consider preemptible or Spot VMs for fault-tolerant batch processing **Configuration Methods** You can set availability policies through the Google Cloud Console, gcloud CLI commands, or Terraform/Deployment Manager templates. These settings are configured at instance creation but can be modified later for some options.
Availability Policy for Compute Engine
Availability policies in Google Compute Engine determine how your virtual machine instances behave during maintenance events and unexpected failures. Understanding these policies is crucial for designing resilient applications that meet your uptime requirements and service level agreements (SLAs). Proper configuration ensures your workloads remain accessible and minimizes disruption to your users.
What is Availability Policy?
An availability policy defines two key behaviors for your Compute Engine instances:
1. On Host Maintenance: This setting determines what happens when Google needs to perform maintenance on the physical host running your VM. Options include:
- Migrate (default): Live migrates your instance to another host
- Terminate: Stops the instance during maintenance
2. Automatic Restart: This setting controls whether your instance automatically restarts if it crashes or is terminated due to a non-user-initiated event. Options include:
- On (default): Instance restarts automatically
- Off: Instance remains stopped
How Availability Policy Works
When you create a VM instance, Google Cloud assigns it to a physical host in your chosen zone. Periodically, Google must perform maintenance on these hosts for security patches, hardware upgrades, or repairs.
With live migration enabled, Google transparently moves your running instance to a different host with minimal interruption, typically just a brief network latency increase. Your applications continue running, and users experience little to no downtime.
If you choose terminate for maintenance behavior, your instance will be stopped when maintenance occurs. Combined with automatic restart enabled, the instance will boot back up once maintenance completes.
Preemptible and Spot VMs have different availability policies. These instances can be terminated at any time with 30 seconds notice and do not support live migration. They are ideal for fault-tolerant batch processing workloads.
Sole-tenant nodes provide dedicated physical servers where only your VMs run, offering additional control over maintenance timing through maintenance windows.
Exam Tips: Answering Questions on Availability Policy
1. Default Settings: Remember that the defaults are live migration ON and automatic restart ON. Questions often test whether you know the default behavior.
2. Preemptible and Spot VMs: These CANNOT use live migration and may be terminated at any time. They are significantly cheaper but less reliable.
3. GPU and Local SSD Instances: VMs with GPUs or local SSDs have limitations on live migration. Know that local SSD data is lost when an instance is terminated.
4. Scenario-Based Questions: When a question describes needing maximum uptime for a standard workload, live migration is the answer. When cost savings is prioritized over reliability, consider preemptible or spot VMs.
5. Managed Instance Groups: These provide additional availability through autohealing, which replaces unhealthy instances automatically. This complements VM-level availability policies.
6. Regional vs Zonal: For highest availability, use regional managed instance groups that distribute instances across multiple zones.
7. Key Terminology: Understand the difference between host maintenance events (planned by Google) and instance failures (unexpected crashes).
8. Configuration Location: Availability policies are set per instance at creation time or can be modified later through the console, gcloud, or API.