0
0
GCPcloud~10 mins

Health checks configuration in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Health checks configuration
Start
Define Health Check Parameters
Create Health Check Resource
Attach Health Check to Backend Service
Health Check Runs Periodically
Check Response Status
Healthy?
YesKeep Backend Serving
No
Mark Backend as Unhealthy
Stop Sending Traffic to Unhealthy Backend
End
This flow shows how a health check is configured, attached, and used to monitor backend health, deciding traffic routing.
Execution Sample
GCP
gcloud compute health-checks create http my-health-check \
  --port 80 \
  --request-path /healthz \
  --check-interval 10s \
  --timeout 5s \
  --unhealthy-threshold 3 \
  --healthy-threshold 1
This command creates an HTTP health check that probes port 80 at path /healthz every 10 seconds, timing out after 5 seconds, marking unhealthy after 3 failures.
Process Table
StepActionParameter/ValueResult/State
1Define health check typeHTTPHealth check type set to HTTP
2Set port80Health check will probe port 80
3Set request path/healthzHealth check requests /healthz path
4Set check interval10sHealth check runs every 10 seconds
5Set timeout5sHealth check waits 5 seconds for response
6Set unhealthy threshold3Backend marked unhealthy after 3 failed checks
7Create health check resourcemy-health-checkHealth check resource created
8Attach to backend servicebackend-service-1Backend service linked to health check
9Health check runsFirst probeBackend responds 200 OK, marked healthy
10Health check runsSecond probeBackend times out, failure count 1
11Health check runsThird probeBackend times out, failure count 2
12Health check runsFourth probeBackend times out, failure count 3, marked unhealthy
13Traffic routingBackend unhealthyTraffic stops routing to this backend
14Health check runsBackend recovers, responds 200 OKBackend marked healthy again, traffic resumes
💡 Health check continuously runs; backend marked unhealthy after 3 failures and healthy after successful response.
Status Tracker
VariableStartAfter Step 9After Step 12After Step 14
failure_count0030
backend_healthunknownhealthyunhealthyhealthy
traffic_routingnot setroutes to backendstops routingroutes to backend
Key Moments - 3 Insights
Why does the backend only get marked unhealthy after 3 failed checks?
Because the unhealthy threshold is set to 3 (see execution_table step 6 and step 12), the system waits for 3 consecutive failures before marking unhealthy to avoid false positives.
What happens if the backend responds successfully after being unhealthy?
As shown in step 14, a successful response resets failure count and marks backend healthy again, resuming traffic routing.
Why is the timeout important in health checks?
Timeout (step 5) defines how long the check waits for a response; if exceeded, it counts as a failure, helping detect unresponsive backends.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at which step does the backend become unhealthy?
AStep 12
BStep 10
CStep 9
DStep 14
💡 Hint
Check the 'Result/State' column in execution_table rows for failure count reaching 3.
According to variable_tracker, what is the failure_count after step 14?
A3
B0
C1
DUnknown
💡 Hint
Look at the failure_count row in variable_tracker under 'After Step 14'.
If the check interval was changed from 10s to 5s, how would the execution_table change?
AUnhealthy threshold would change to 5
BTimeout would increase to 10s
CHealth checks would run twice as often, steps 9-14 would happen faster
DBackend would never be marked unhealthy
💡 Hint
Check step 4 in execution_table about check interval and its effect on health check frequency.
Concept Snapshot
Health checks monitor backend health by sending requests at intervals.
Configure type, port, path, interval, timeout, and thresholds.
Failures count until unhealthy threshold marks backend unhealthy.
Healthy backends receive traffic; unhealthy ones do not.
Recovery happens when backend responds successfully again.
Full Transcript
Health checks configuration in GCP involves defining parameters like type (HTTP), port, request path, check interval, timeout, and unhealthy threshold. The health check resource is created and attached to a backend service. The health check runs periodically, sending requests to the backend. If the backend responds successfully, it is marked healthy and receives traffic. If it fails consecutively as per the unhealthy threshold, it is marked unhealthy and traffic stops routing to it. When the backend recovers and responds successfully, it is marked healthy again and traffic resumes. This process ensures only healthy backends serve traffic, improving reliability.