Status
Current state: "DRAFT"
Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]
JIRA:
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
KIP-302 introduced "use_all_dns_ips"
value for client.dns.lookup
configuration to make the NIO client trying all the possible IP's of a hostname before failing the connection to that hostname.
It explicitly rejects making "use_all_dns_ips"
as the default to avoid impacting existing users, but it did not explain what the impact is.
With this KIP, we would like to argue that it is desirable to make "use_all_dns_ips"
or its behaviour as the default value for client.dns.lookup
for these reasons:
- reduce connection failure rates by using all the possible IP addresses of a hostname
- common expectation of applications dealing with hostname resolved to multiple IP addresses is to attempt connecting to all of them and use the one it can connect successfully, not to use the first one
- resolving hostname to multiple IP addresses is becoming more common due to the rise of cloud and containerised environment
Public Interfaces
The behaviour of "default"
value for client.dns.lookup
changes from "using the first resolved IP" to "using one of the resolved IP's, whichever gets successful connection first".
To achieve the old behaviour of using the first resolved IP, add new possible value for client.dns.lookup
configuration: "use_first_dns_ips"
.
Proposed Changes
Change ClientUtils#resolve to:
- If
client.dns.lookup
value is either"default"
or"use_all_dns_ips"
: Attempt connecting to each resolved IP addresses and use the first one that connects successfully. - If
client.dns.lookup
value is"use_first_dns_ips"
: Use the first resolved IP address.
Compatibility, Deprecation, and Migration Plan
- If a hostname resolves to multiple IP addresses and connecting to the first IP failed, the client will attempt to connect to the other IP's instead of failing. Based on the common expectation, this is what is expected.
- If a hostname resolves to a single IP address and connecting to it failed, then the connection will fail.
Rejected Alternatives
- Keep the default behaviour of
client.dns.lookup
to connect to the first resolved IP. The reason this is rejected is because it does not match with the common expectation when a hostname resolves to multiple IP addresses. - Remove
"default"
value fromclient.dns.lookup
. There is a lot of places in the server code that uses"default"
value, so removing"default"
value would require changing many server code, which is high risk.