Health checks configuration in GCP - Mini Project: Build & Apply
health_check with the key name set to "my-health-check".Use a Python dictionary with the key name and value "my-health-check".
type with value "HTTP" and port with value 80 to the health_check dictionary.Add "type": "HTTP" and "port": 80 inside the dictionary.
requestPath with value "/health", checkIntervalSec with value 5, and timeoutSec with value 3 to the health_check dictionary.Add the keys for the request path and timing inside the dictionary.
unhealthyThreshold with value 2 and healthyThreshold with value 3 to the health_check dictionary to complete the configuration.Set the thresholds for healthy and unhealthy checks.
Practice
What is the main purpose of a health check in Google Cloud Platform?
Solution
Step 1: Understand health check function
Health checks regularly test if servers respond correctly to requests.Step 2: Identify main purpose
This helps detect unhealthy servers so they can be fixed or replaced.Final Answer:
To monitor if servers are working properly -> Option BQuick Check:
Health check = Monitor server health [OK]
- Confusing health checks with backups
- Thinking health checks increase speed
- Assuming health checks add storage
Which of the following is the correct way to specify a TCP health check in a Google Cloud load balancer configuration?
{
"type": "TCP",
"port": 80,
"checkIntervalSec": 5
}Solution
Step 1: Identify correct health check type
TCP health checks use "type": "TCP" to test TCP connections on the port.Step 2: Match correct JSON syntax
The example matches the correct syntax with type TCP, port 80, and interval 5 seconds.Final Answer:
{ "type": "TCP", "port": 80, "checkIntervalSec": 5 } -> Option AQuick Check:
TCP type with port 80 = { "type": "TCP", "port": 80, "checkIntervalSec": 5 } [OK]
- Using HTTP instead of TCP for TCP check
- Using unsupported types like UDP or ICMP
- Wrong JSON syntax or missing fields
Given this health check configuration snippet, what will happen if the server does not respond within 10 seconds?
{
"type": "HTTP",
"port": 8080,
"timeoutSec": 10,
"unhealthyThreshold": 3
}Solution
Step 1: Understand timeout and threshold
The timeoutSec of 10 means the check waits 10 seconds for a response before failing.Step 2: Apply unhealthyThreshold logic
The server must fail 3 consecutive checks to be marked unhealthy.Final Answer:
The server is marked unhealthy after 3 failed checks -> Option AQuick Check:
Timeout + 3 failures = unhealthy after 3 tries [OK]
- Thinking server is removed immediately after 1 failure
- Ignoring unhealthyThreshold setting
- Assuming server restarts automatically
Identify the error in this health check configuration snippet:
{
"type": "HTTP",
"port": "eighty",
"requestPath": "/health",
"checkIntervalSec": 5
}Solution
Step 1: Check port field type
The port value is "eighty" as a string, but it must be a numeric value like 80.Step 2: Validate other fields
requestPath is valid for HTTP, checkIntervalSec can be 5, and type "HTTP" is correct.Final Answer:
Port must be a number, not a string -> Option CQuick Check:
Port number must be numeric [OK]
- Using string instead of number for port
- Thinking requestPath is invalid for HTTP
- Assuming checkIntervalSec minimum is 10
You want to configure a health check that verifies your web app responds with HTTP 200 on path /status every 15 seconds, and marks the server unhealthy after 2 failures. Which configuration is correct?
Solution
Step 1: Match health check type and path
The app uses HTTP checks on path "/status" so type must be "HTTP" and requestPath "/status".Step 2: Verify timing and thresholds
Check interval is 15 seconds and unhealthyThreshold is 2, matching requirements.Step 3: Confirm port number
Port 80 is standard for HTTP, so it fits the web app default.Final Answer:
{ "type": "HTTP", "port": 80, "requestPath": "/status", "checkIntervalSec": 15, "unhealthyThreshold": 2 } -> Option DQuick Check:
HTTP + /status + 15s + 2 failures = { "type": "HTTP", "port": 80, "requestPath": "/status", "checkIntervalSec": 15, "unhealthyThreshold": 2 } [OK]
- Using TCP type for HTTP path
- Wrong requestPath or port
- Incorrect checkIntervalSec or unhealthyThreshold
Ready to prove it?
Pass the test and this pattern moves unknown
