Course contentsShow
← Cloud and Infrastructure
Lesson 329 of 2,9896. Auto ScalingFree lesson

MIG Health Checks and Autohealing

Defining health check criteria, autohealing policies, and initial delay settings.

MIG Health Checks and Autohealing

You'll learn how Google Cloud's Managed Instance Groups detect unhealthy VMs and automatically replace them to maintain application reliability.

What Are MIG Health Checks?

Health checks are periodic "wellness tests" that your MIG performs on each VM instance. Think of them like a doctor's checkup: the system asks "Are you healthy?" by sending requests to specific endpoints (like an HTTP path or TCP port). If an instance fails to respond correctly multiple times, it's marked unhealthy.

How Autohealing Works

Autohealing is the automatic recovery mechanism. When a VM fails its health checks, the MIG doesn't just flag it—it deletes the unhealthy instance and creates a fresh replacement. This ensures your group always maintains the desired number of healthy instances without manual intervention.

Key Configuration Elements

Health Check Criteria

You define what "healthy" means:

  • Protocol: HTTP, HTTPS, TCP, or SSL
  • Port: Which port to check (e.g., 80, 443)
  • Path: For HTTP checks, which URL path to test (e.g., /health)
  • Success thresholds: How many consecutive passes before marking healthy
  • Failure thresholds: How many consecutive failures trigger unhealthy status

Initial Delay

This is the grace period after an instance launches before health checks begin. Brand-new VMs need time to boot up and start their applications—you wouldn't want them marked unhealthy while still starting! Set this to match your application's typical startup time (e.g., 300 seconds).

Why This Matters

Without autohealing, a crashed VM would sit idle, reducing your capacity. With it enabled, your MIG self-heals automatically, maintaining availability even when individual instances fail.

Key Takeaway: MIG health checks monitor instance health using customizable criteria, and autohealing automatically replaces failed VMs after an initial delay period, ensuring your application stays resilient without manual intervention.