0
0
Kubernetesdevops~5 mins

Readiness probe concept in Kubernetes - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Readiness probe concept
O(n)
Understanding Time 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?

Scenario Under Consideration

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 Repeating Operations

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.
How Execution Grows With Input

As the number of pods (n) increases, the total number of readiness checks grows proportionally.

Input Size (n)Approx. Operations per Period
10 pods10 HTTP checks every 10 seconds
100 pods100 HTTP checks every 10 seconds
1000 pods1000 HTTP checks every 10 seconds

Pattern observation: The number of readiness probe checks grows linearly with the number of pods.

Final Time Complexity

Time Complexity: O(n)

This means the total readiness probe checks increase directly with the number of pods running.

Common Mistake

[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.

Interview Connect

Understanding how readiness probes scale helps you design efficient Kubernetes clusters and shows you can think about system behavior as it grows.

Self-Check

"What if the readiness probe periodSeconds is halved? How would that affect the time complexity?"