Readiness probe concept in Kubernetes - Time & Space Complexity
We want to understand how the time cost of Kubernetes readiness probes changes as the number of pods grows.
Specifically, how does checking readiness scale when many pods run in a cluster?
Analyze the time complexity of the following readiness probe configuration.
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: example-container
image: example-image
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
This code sets 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 repeatedly sends HTTP GET requests to the pod's /health endpoint.
- How many times: This happens every 10 seconds for each pod until the pod is ready.
As the number of pods (n) increases, the total number of readiness checks grows proportionally.
| Input Size (n) | Approx. Operations per Period |
|---|---|
| 10 pods | 10 HTTP checks every 10 seconds |
| 100 pods | 100 HTTP checks every 10 seconds |
| 1000 pods | 1000 HTTP checks every 10 seconds |
Pattern observation: The number of readiness probe checks grows linearly with the number of pods.
Time Complexity: O(n)
This means the total readiness probe checks increase directly with the number of pods running.
[X] Wrong: "Readiness probes run once and then stop, so their cost does not grow with more pods."
[OK] Correct: Readiness probes run repeatedly for each pod until it becomes ready, so more pods mean more repeated checks.
Understanding how readiness probes scale helps you design efficient Kubernetes clusters and shows you can think about system behavior as it grows.
"What if the readiness probe periodSeconds is halved? How would that affect the time complexity?"