17

I'm wondering what timeoutSeconds actually does in a liveness or readiness probes?

The documentation states that:

timeoutSeconds: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1.

No more explanation or demonstration of how to use it and what actually it does.

So what is this parameter's job and how can it be differentiated from periodSeconds?

I was lucky to find this answer but it's still fuzzy to me. Specially after I saw this diagram from here:

enter image description here

I also tried playing around with the values to find out how things work and what is the effect of this parameter but no luck as events do not seem to take place immediately.

Ravexina
  • 2,406
  • 2
  • 25
  • 41

2 Answers2

30

The periodSeconds specifies how often a container running within a pod will be probed (tested) and the timeoutSeconds specifies how quickly the container needs to respond to the probe.

Let's say that you have set periodSeconds to 3 and timeoutSeconds to 1. In this setup, container will be probed every 3 seconds and each time it is being probed, it has 1 second to respond otherwise it fails that one probe (even if it responds later to that probe, say in 2 seconds).

The diagram is quite precise. It tells you that nothing is happening during the initialDelaySeconds which is a time the container has before it starts being probed (so that it has enough time to start all the necessary processes). After this time expires, it starts being probed.

It successfully responds to the first probe within timeoutSeconds, then there is a delay periodSeconds before it is probed again. This time it fails to respond within timeoutSeconds and there is another periodSeconds delay and it fails again and again and then then pod is being restarted because that is how it was configured in this case (to restart after 3 consecutively failed probes, given by failureThreshold)

Matus Dubrava
  • 13,637
  • 2
  • 38
  • 54
  • 5
    OK. but what if`timeoutSeconds > periodSeconds`? The tests never fail and/or the requests accumulate? – titou10 Jan 28 '21 at 18:40
  • 4
    `periodSeconds` only tells you how often the probe is sent. You can have more probes in "pending" state than the count of `failure/successThreshold`. The thresholds will be evaluated as the probes resolve (you can say that they will accumulate if it means that you have more than 1 unresolved probe at the same time). It is not mentioned in the picture just because there is hardly any sensible reason to make such configuration. If you have a need to evaluate more probes in the same time interval then you can just lower the threshold to achieve the same effect. – Matus Dubrava Jan 28 '21 at 20:07
  • So let's say if I give liveness config something like this: `timeout=60s` `period=30s` so does it mean it would still show failure thresholds even if the probe was resolved after that? – Mirav T. Mehta Jan 20 '22 at 10:44
1

It's the maximum amount of seconds allowed for the (assuming you're using an HTTP readiness probe) web server to respond to the request.

Yarden Shoham
  • 201
  • 2
  • 9