DNS-aware Persistent Connections

What exactly is the problem statement?

Is that even a valid problem?

Let’s demo the issue

package mainimport (
"io"
"io/ioutil"
"log"
"net"
"net/http"
"time"
)
func main() {
tr := &http.Transport{
DialContext: (&net.Dialer{
Timeout: 5 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
TLSHandshakeTimeout: 5 * time.Second,
IdleConnTimeout: 100 * time.Second,
}
go func(rt http.RoundTripper) {
for {
time.Sleep(1 * time.Second)
c := http.Client{Transport:tr}
resp, err := c.Get("http://api.razorpay.com")
if err != nil {
log.Printf("Failed to do request: %v", err)
continue
}

io.Copy(ioutil.Discard, resp.Body)
resp.Body.Close()
log.Printf("resp status: %v", resp.Status)
}
}(tr)
ch := make(chan struct{})
<-ch
}
2020/08/02 01:17:45 resp status: 200 OK
2020/08/02 01:17:46 resp status: 200 OK
2020/08/02 01:17:48 resp status: 200 OK
2020/08/02 01:17:50 resp status: 200 OK

The solution

Why is this a responsibilty of the server to terminate connections?

Where do load balancers fit into the picture here?

What about http2?

Strict DNS based service discovery in envoy

The 421 (Misdirected Request) status code in http2

But I would still want to handle this at my client.

Summary

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store