Files
PAVANSAI KUMAR ALLADIandPavan sai kumar alladi 9f506606a9 Add dnsResolver configuration option for randomized DNS load balancing (#3577)
### Motivation:

When connecting to services with multiple DNS records (e.g. Kubernetes
headless services), getaddrinfo returns addresses in a deterministic
order, causing all connections to go to the same backend. SwiftNIO now
provides a RandomizedDNSResolver that shuffles results.

### Modifications:

Add a dnsResolver property to HTTPClient.Configuration with two options:
.system (default, current behavior) and randomized (uses NIO's
RandomizedDNSResolver to shuffle DNS results). Apply the resolver to
ClientBootstrap during connection creation.

### Result:

Users can opt into randomized DNS resolution by setting
config.dnsResolver = .randomized, enabling load distribution across
multiple backend IPs while preserving the default behavior.

---------

Co-authored-by: Pavan sai kumar alladi <p_alladi@apple.com>
2026-05-17 21:53:29 +00:00
..