Rest API Timeout and DNS Round Robin – Something to Be Aware Of

Let me first explain the ConnectTimeout

  • Connection timeout is used when opening a communications link to the remote resource.
  • A java.net.SocketTimeoutException is thrown if the timeout expires before the connection can be established.

@DebugHorror Point 3 DNS Resolution is the main culprit in this case.

  • It’s quite common that some larger domains will be using a DNS round robin configuration – essentially having the same domain mapped to multiple IP addresses.
  • This introduces a new challenge for a timeout against such a domain, simply because of the way HttpClient will try to connect to that domain that times out:
  • HttpClient gets the list of IP routes to that domain:
    • it tries the first one – that times out (with the timeouts we configure(15 sec))
    • it tries the second one – that also times out (15 sec)
    • and so on …

We can see the same in below screenshot:

3 Likes