Skip to content

HTTP/2 transport wrapper for client-side load balancing in Kubernetes

License

Notifications You must be signed in to change notification settings

go-tk/kubetransport

Repository files navigation

kubetransport

GoDev Workflow Status Coverage Status

HTTP/2 transport wrapper for client-side load balancing in Kubernetes

Problem

When an HTTP/2 client sends a request to an HTTP/2 server, a persistent connection between the client and the server is established, and thanks to the multiplexing feature of the HTTP/2 protocol, all the subsequent requests from the client can go through this connection concurrently without establishing additional connections, which significantly improves the use of network resources.

Unfortunately, the persistent connection also comes with a side effect that it breaks the load balancing in Kubernetes. Let's say there are three server instances behind a Kubernetes Service FQDN and our client send out requests with this FQDN, which will result in a persistent connection established with only one of the server instances, and no traffic will reach the other server instances.

Solution

Kubernetes provides Endpoints API to retrieve and watch the endpoints information of a Service which contains the IP addresses of server instances. If we intercept every request sent out and replace the hostname (FQDN) in its URL with one of the IP addresses randomly, the load balancing can work again. For intercepting outgoing requests, we can simply wrap the HTTP transport.

That is all about what this package did.

About

HTTP/2 transport wrapper for client-side load balancing in Kubernetes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages