<p>I understand how to set up a readiness probe in kubernetes, but are there any best practices about what the microservice should actually check when the readiness probe is called? Two specific examples:</p>
<ol>
<li>A microservice that fronts a db where without a functioning db connection, practically all functionality will not work. Here I think pinging the db would be reasonable, failing the readiness check if ping fails. Is this recommended?</li>
<li>A microservice that uses N other microservices, but where failure to connect to any one would still allow for a majority of the functionality to work. Here I think checking for connectivity to the backing services is ill advised. In this case, assuming there is no extensive &quot;boot&quot; or &quot;warm up&quot; processing, liveness and readiness are equivalent. Correct?</li>
</ol>
<p>Thank you</p>

user2133814
<p>No, I don't think there are best practise for readiness probes.</p>
<p>It all depends on applciation and what you exepct to happen.</p>
<blockquote>
<p>Here I think pinging the db would be reasonable, failing the readiness check if ping fails</p>
</blockquote>
<p>I will try to comment on this. Let's imagine you have some backend microservice (deployment with serveral replicas) and it's communicating with a db. When db fails (assuming no replication or some serious db downtime), your pod replicas' readiness probes start to fail and the pods' endpoints are being deleted from the Service. Now when client tries to access the service, it will result in connection timeout because no service is there to handle the request.</p>
<p>You have to ask yourself if this is the behaviuor you want/expect or maybe it would be much more convinient for the readiness probe not to fail when db fails, microservice would still handle traffic in this case, and would be able to return an error message to the client informing him about the problem.</p>
<p>Even simple 503 would be much better in this case. Getting an actual error message tells me much more about the actual issue than getting <em>connection timeout</em>.</p>
<hr />
<blockquote>
<p>[...] but where failure to connect to any one would still allow for a majority of the functionality to work. Here I think checking for connectivity to the backing services is ill advised. In this case, assuming there is no extensive &quot;boot&quot; or &quot;warm up&quot; processing, liveness and readiness are equivalent.</p>
</blockquote>
<p>It depends on the usecase. In application code you can react much quicker to problems that happen to backing services and I would use this approach whenever I can, and only use readiness for checking backing services whenever it can't be handled differently.</p>
<hr />
<p>So for me liveness probe answers the question: &quot;Is this application still running?&quot;
And readines proble answers the question: &quot;Is this application <em>ready to handle/capable of handling</em> the traffic?&quot;</p>
<p>And it's up to you to define what does it mean to &quot;still run&quot; and &quot;be able to handle traffic&quot;.</p>
<p>But usually if appliation is running, it is also able to handle the traffic so in this case liveness and readiness are indeded equal.</p>
