I use okhttp for communicating between backend microservices. The service discovery is implemented on top of consul dns. As a result some instances/pods, associated to a given IP can be removed at any time. The problem is that okhttp caches the resolved ip address and when some associated instance becomes unavailable we see spikes of java.net.SocketTimeoutException.
I would like to understand, how does the dns cache is invalidated?