Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

HTTP requests to a headless k8s service not getting load balanced with go1.22.7

144 views
Skip to first unread message

Nishant Gupta

unread,
Sep 27, 2024, 5:07:29 PM9/27/24
to golang-nuts

Hi,

I have a headless k8s service for which the local DNS resolver gives all the IPs of the pods sitting behind the service. The requests made to the service are not getting load balanced with go1.22.7 and all the requests go to a single pod. The HTTP client is invoked using the following snippet:

```

for { client := &http.Client{ Timeout: 95 * time.Second, } req, err := http.NewRequest("GET", "http://<service-name>:<port>", nil) if err != nil { fmt.Println("Error creating request:", err) return } resp, err := client.Do(req) if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() time.Sleep(5 * time.Second) }

```

Requests made from the above with go1.23.1 are getting load balanced appropriately(not sure if it’s round robin though). I compared the transport logic for both the versions but couldn’t find anything concrete which could cause this problem. Can you experts please help me out?

Thanks,
Nishant

Lin Lin

unread,
Nov 19, 2024, 1:26:23 AM11/19/24
to golang-nuts
I've ran some tests as follow, failed to see the load balancing in both go1.22 and go1.23.

1. setup a coredns to provide dns service.
2. assign additional IP to the NIC.
3. run 2 http server with flask on each IP address.
4. using http.client to request that server.

So I  dout if that is a Go behavior changing.

I have a not so clever suggestion if you have some time. With git bisect, compiling the Go source code, to find the very commit 'causing' the changing.
Reply all
Reply to author
Forward
0 new messages