Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ public BlobClient(InetSocketAddress serverAddress, Configuration clientConfig)
}

// Establish the socket using the hostname and port. This avoids a potential issue where
// the
// InetSocketAddress can cache a failure in hostname resolution forever.
// the InetSocketAddress can cache a failure in hostname resolution forever.
// Use getHostString() instead of getHostName() to avoid unnecessary reverse DNS and DNS
// lookups when addresses are specified as IP literals. This improves reliability and
// reduces latency for each blob transfer.
socket.connect(
new InetSocketAddress(serverAddress.getHostName(), serverAddress.getPort()),
new InetSocketAddress(serverAddress.getHostString(), serverAddress.getPort()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good. nit: I wonder if we could add a comment to explain why we do. not use getHostName. Maybe include some of the following reasons: Addresses are often configured as IP addresses for reliability
DNS may be unavailable or slow in containerized/cloud environments
Every blob transfer would trigger unnecessary reverse DNS lookups
Connection failures could occur if DNS resolution fails

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I’ve updated the code comment to explain the reason.

clientConfig.get(BlobServerOptions.CONNECT_TIMEOUT));
socket.setSoTimeout(clientConfig.get(BlobServerOptions.SO_TIMEOUT));
} catch (Exception e) {
Expand Down