Why probes keep applications healthy in Kubernetes - Performance Analysis
We want to understand how the time it takes to check application health grows as the number of pods increases.
How does Kubernetes manage many health checks efficiently?
Analyze the time complexity of the following Kubernetes readiness probe configuration.
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: app-container
image: myapp:latest
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
This snippet configures a readiness probe that checks the /health endpoint every 10 seconds after a 5-second delay.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Kubernetes performs HTTP GET requests to the /health endpoint repeatedly.
- How many times: Each pod runs this check every 10 seconds continuously.
As the number of pods increases, the total number of health checks grows proportionally.
| Input Size (pods) | Approx. Health Checks per 10 seconds |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The total checks increase linearly as more pods are added.
Time Complexity: O(n)
This means the total health check operations grow directly in proportion to the number of pods.
[X] Wrong: "Health checks run once and then stop, so adding more pods doesn't increase checks."
[OK] Correct: Health probes run repeatedly to keep checking pod status, so more pods mean more checks over time.
Understanding how repeated health checks scale helps you design systems that stay reliable as they grow.
"What if the probe interval is halved? How would the time complexity change?"
Practice
Solution
Step 1: Understand liveness probe role
Liveness probes check if the app is alive and working properly.Step 2: Identify action on failure
If the liveness probe fails, Kubernetes restarts the app to fix it.Final Answer:
To check if the application is running and restart it if it is not healthy -> Option AQuick Check:
Liveness probe = restarts unhealthy app [OK]
- Confusing liveness with readiness probe
- Thinking liveness controls traffic
- Assuming liveness updates configs
Solution
Step 1: Identify readiness probe syntax
Readiness probes often use httpGet with path and port defined.Step 2: Match correct YAML structure
readinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: 5 periodSeconds: 10 shows readinessProbe with httpGet, initialDelaySeconds, and periodSeconds correctly.Final Answer:
readinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: 5 periodSeconds: 10 -> Option AQuick Check:
Readiness probe syntax = readinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: 5 periodSeconds: 10 [OK]
- Mixing liveness and readiness probe syntax
- Using startupProbe instead of readinessProbe
- Incorrect indentation or missing fields
readinessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 5
periodSeconds: 10Solution
Step 1: Understand readiness probe effect
Readiness probe controls if pod is ready to get user traffic.Step 2: Identify behavior on failure
If readiness probe fails, pod stays running but is removed from service endpoints, so no new traffic.Final Answer:
The pod stops receiving new traffic but keeps running -> Option BQuick Check:
Readiness failure = no traffic, pod runs [OK]
- Thinking readiness failure restarts pod
- Confusing readiness with liveness probe
- Assuming pod deletion on readiness failure
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
What is the most likely cause?Solution
Step 1: Analyze liveness probe behavior
Liveness probe checks /health on port 8080 every 10 seconds after 5 seconds delay.Step 2: Understand restart cause
If app does not respond correctly 3 times (failureThreshold), Kubernetes restarts pod.Final Answer:
The application is not responding to the /health endpoint in time -> Option DQuick Check:
Liveness failure = app not responding, causes restart [OK]
- Assuming readiness probe causes restart
- Ignoring failureThreshold effect
- Blaming resource limits without evidence
Solution
Step 1: Identify probe controlling traffic
Readiness probe controls when app receives user traffic.Step 2: Choose probe matching app readiness
Readiness probe checking /ready after data load ensures traffic only after app is ready.Step 3: Exclude other options
Liveness restarts app but does not control traffic; startup probe delays startup but not traffic control.Final Answer:
Use a readiness probe that checks a /ready endpoint returning success after data load -> Option CQuick Check:
Readiness probe controls traffic flow [OK]
- Using liveness probe to control traffic
- Confusing startup probe with readiness probe
- Checking same endpoint for both probes
Ready to prove it?
Pass the test and this pattern moves unknown
