GrabRyan LawProblem & solution
DNS Resolution in Go and Cgo
Summary
Go applications experiencing load balancing issues across AWS Elastic Load Balancer (ELB) nodes trace uneven traffic distribution to IP address sorting defined in RFC 6724. Comparing Go's native DNS resolver with Cgo and glibc's getaddrinfo shows that both initially sort destination addresses using Rule 9 longest matching prefix rules. Disabling IPv6 on the network interface causes C and Cgo resolvers to return IP addresses in randomized order, while the native Go resolver continues deterministic sorting. Examination of net/addrselect.go reveals that Go's native resolver implements only a subset of the RFC rules and omits dynamic source address selection. Achieving permanent parity requires modifying the Go source code directly.
Context
A load balancing issue occurred on AWS Elastic Load Balancer (ELB) nodes due to deterministic IP address sorting under RFC 6724.
Approach / What changed
Investigated DNS resolution across native Go, Cgo, and C by comparing getaddrinfo behavior with Go's net package, disabling interface-level IPv6, and reviewing net/addrselect.go.
Takeaways
Go's native DNS resolver implements only a subset of RFC 6724 rules and lacks dynamic source address selection.
Disabling IPv6 on the network interface randomizes address order for Cgo and C resolvers using getaddrinfo, but does not affect Go's native resolver.
Cgo executes C code on an operating system thread rather than on a lightweight goroutine.
Source and freshness
- Source
- engineering.grab.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.