Bird
Raised Fist0
GCPcloud~10 mins

High availability configuration in GCP - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - High availability configuration
Start: User requests service
↓
Load Balancer receives request
↓
Check: Are multiple instances available?
No→Create more instances
Yes↓
Distribute request to healthy instance
↓
Instance processes request
↓
Monitor instance health
↓
If instance fails, redirect traffic to healthy instances
↓
Continue serving requests without downtime
The flow shows how a load balancer directs user requests to multiple instances, monitors their health, and ensures traffic is only sent to healthy instances to maintain service availability.
Execution Sample
GCP
resource "google_compute_instance_template" "template" {
  name = "my-instance-template"
  machine_type = "e2-medium"
  disk {
    boot = true
    auto_delete = true
    initialize_params {
      image = "debian-cloud/debian-10"
    }
  }
  network_interface {
    network = "default"
    access_config {}
  }
}

resource "google_compute_instance_group_manager" "igm" {
  name = "my-instance-group"
  base_instance_name = "my-instance"
  instance_template = google_compute_instance_template.template.self_link
  target_size = 2
}

resource "google_compute_health_check" "hc" {
  name = "my-health-check"
  tcp_health_check {
    port = 80
  }
}

resource "google_compute_region_backend_service" "backend" {
  name = "my-backend-service"
  backends {
    group = google_compute_instance_group_manager.igm.instance_group
  }
  health_checks = [google_compute_health_check.hc.self_link]
}
This Terraform code creates an instance template, a managed instance group with two instances, a health check to monitor instance health, and a backend service linked to the group for high availability.
Process Table
StepActionResource StateResult
1Create instance templateTemplate createdReady for instances
2Create instance group manager with target_size=22 instances createdInstances running
3Create health check on port 80Health check activeMonitors instance health
4Create backend service linked to instance groupBackend service activeLoad balancer can route traffic
5Load balancer receives requestInstances healthyRequest routed to instance 1
6Instance 1 fails health checkInstance 1 marked unhealthyTraffic rerouted to instance 2
7Instance 1 recoversInstance 1 healthy againTraffic balanced between instances
8Scale instance group to 33 instances runningMore capacity for requests
9Load balancer distributes requestsAll instances healthyRequests balanced across 3 instances
10TerminateAll systems healthyHigh availability maintained
💡 Execution stops as system maintains high availability with healthy instances serving requests.
Status Tracker
VariableStartAfter Step 2After Step 6After Step 7After Step 8Final
instance_count022233
instance_1_healthunknownhealthyunhealthyhealthyhealthyhealthy
instance_2_healthunknownhealthyhealthyhealthyhealthyhealthy
instance_3_healthunknownn/an/an/ahealthyhealthy
traffic_distributionnonebalanced between 2all to instance 2balanced between 2balanced between 3balanced between 3
Key Moments - 3 Insights
Why does traffic stop going to instance 1 at step 6?
At step 6, instance 1 fails the health check and is marked unhealthy, so the load balancer stops sending traffic to it to avoid downtime, as shown in the execution_table row 6.
What happens when the instance group scales from 2 to 3 instances at step 8?
At step 8, the instance group increases to 3 instances, adding capacity. The load balancer then distributes traffic across all healthy instances, as seen in rows 8 and 9.
How does the health check affect high availability?
The health check monitors instance health continuously. If an instance is unhealthy, traffic is rerouted to healthy instances, ensuring no downtime, demonstrated in steps 3, 6, and 7.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 6. What is the health status of instance 1?
AHealthy
BUnhealthy
CUnknown
DTerminated
💡 Hint
Check the 'Resource State' column in row 6 of the execution_table.
At which step does the instance group scale to 3 instances?
AStep 4
BStep 7
CStep 8
DStep 9
💡 Hint
Look for the step mentioning scaling in the 'Action' column of the execution_table.
If instance 2 became unhealthy at step 9, what would happen to traffic distribution?
ATraffic would be routed only to instance 1 and 3
BTraffic would stop completely
CTraffic would be routed only to instance 3
DTraffic would be routed to instance 2 anyway
💡 Hint
Refer to how traffic is rerouted when an instance is unhealthy in the execution_table steps 6 and 7.
Concept Snapshot
High availability uses multiple instances behind a load balancer.
Health checks monitor instance status.
Unhealthy instances are removed from traffic rotation.
Scaling adds more instances for capacity.
This setup ensures continuous service without downtime.
Full Transcript
High availability configuration in cloud infrastructure means setting up multiple instances of a service so that if one fails, others can take over. A load balancer receives user requests and sends them to healthy instances only. Health checks continuously monitor each instance's status. If an instance becomes unhealthy, the load balancer stops sending traffic to it and redirects to healthy ones. Scaling the instance group adds more instances to handle more requests. This process ensures the service stays available without interruption.

Practice

(1/5)
1. What is the main purpose of configuring high availability in a cloud service?
easy
A. To make the service run faster for a single user
B. To reduce the cost of running the service
C. To limit the number of users accessing the service
D. To keep the service running even if some parts fail

Solution

  1. Step 1: Understand high availability concept

    High availability means the system stays up and working even if some components fail.
  2. Step 2: Identify the main goal

    The goal is to avoid downtime and keep the service accessible to users.
  3. Final Answer:

    To keep the service running even if some parts fail -> Option D
  4. Quick Check:

    High availability = service stays running despite failures [OK]
Hint: High availability means no downtime during failures [OK]
Common Mistakes:
  • Confusing high availability with cost reduction
  • Thinking it only improves speed for one user
  • Assuming it limits user access
2. Which GCP resource helps automatically replace unhealthy VM instances to maintain high availability?
easy
A. Managed Instance Group with health checks
B. Cloud Storage Bucket
C. Cloud SQL instance
D. Cloud Functions

Solution

  1. Step 1: Identify resource for auto healing

    Managed Instance Groups (MIGs) can use health checks to detect unhealthy VMs.
  2. Step 2: Understand auto replacement

    MIGs automatically recreate unhealthy instances to keep the service healthy.
  3. Final Answer:

    Managed Instance Group with health checks -> Option A
  4. Quick Check:

    Auto replace unhealthy VMs = Managed Instance Group + health checks [OK]
Hint: Auto healing uses Managed Instance Groups with health checks [OK]
Common Mistakes:
  • Choosing storage or database services instead of compute
  • Confusing Cloud Functions with VM management
  • Ignoring health checks role
3. Consider a Managed Instance Group spread across two zones with health checks enabled. If one zone fails completely, what happens to the instances?
medium
A. Instances in the failed zone are replaced in the same zone
B. Instances in the failed zone remain down until manual restart
C. Instances in the failed zone are replaced in the other zone
D. All instances in both zones are shut down

Solution

  1. Step 1: Understand multi-zone MIG behavior

    MIGs spread instances across zones for fault tolerance.
  2. Step 2: Analyze failure impact

    If one zone fails, MIG recreates instances in healthy zones to maintain capacity.
  3. Final Answer:

    Instances in the failed zone are replaced in the other zone -> Option C
  4. Quick Check:

    Zone failure triggers instance replacement in healthy zones [OK]
Hint: MIGs replace failed zone instances in other zones automatically [OK]
Common Mistakes:
  • Thinking instances are replaced in the failed zone
  • Assuming manual restart is needed
  • Believing all instances shut down
4. You configured a Managed Instance Group with health checks, but unhealthy instances are not being replaced. What is the most likely cause?
medium
A. Autohealing is disabled in the instance group
B. Instances are in multiple zones
C. Health check is not attached to the instance group
D. Firewall rules block all traffic

Solution

  1. Step 1: Check health check attachment

    Health checks must be attached to trigger autohealing, but this alone is not enough.
  2. Step 2: Verify autohealing setting

    Autohealing must be enabled in the instance group to replace unhealthy instances.
  3. Final Answer:

    Autohealing is disabled in the instance group -> Option A
  4. Quick Check:

    Autohealing disabled = no instance replacement [OK]
Hint: Autohealing must be enabled to replace unhealthy instances [OK]
Common Mistakes:
  • Assuming health check attachment alone triggers replacement
  • Blaming multi-zone setup
  • Ignoring autohealing configuration
5. You want to design a highly available web application on GCP that remains online even if an entire zone fails. Which combination of configurations best achieves this?
hard
A. Single-zone Managed Instance Group with health checks and autoscaling
B. Multi-zone Managed Instance Group with health checks and autoscaling
C. Single VM instance with a static IP and firewall rules
D. Cloud Storage bucket with versioning enabled

Solution

  1. Step 1: Understand zone failure impact

    A single zone failure can take down all instances in that zone if only single-zone is used.
  2. Step 2: Choose multi-zone MIG with health checks and autoscaling

    This setup spreads instances across zones, replaces unhealthy ones, and adjusts capacity automatically.
  3. Step 3: Evaluate other options

    Single-zone lacks zone failure protection; single VM is a single point of failure; storage bucket is not compute.
  4. Final Answer:

    Multi-zone Managed Instance Group with health checks and autoscaling -> Option B
  5. Quick Check:

    Multi-zone MIG + health checks + autoscaling = high availability [OK]
Hint: Use multi-zone MIG with health checks and autoscaling for best availability [OK]
Common Mistakes:
  • Choosing single-zone MIG ignoring zone failure
  • Using single VM which is a single failure point
  • Confusing storage bucket with compute resources
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard