Question:
-
GRPC uses the pod originally linked by default in K8S.
-
Http1.1 can normally use multiple Pods under Service on K8S
-
Analysis:
The implementation principle of golang HTTP Client
(reuse others, too lazy) of the core
Graph of TD [roundTrip] -- > B [getConn] -- > B | | existence C [queueForIdleConn exists free link] - > | no | D [queueForDial] D - > E [open coroutines dialConnFor] E --> F[pconn.readLoop writeLoop]
methods
pconn:=list[len(list)- 1] each time the last pCONN is fetched from the idle ListConnect, the loop is used. When and if?Copy the code
- How to manage gRPC links
How to obtain the address to create the HTTP2 link through the loadresolver is not described here
See http2Client only has conn, which by default does not use link pooling.
The reason:
-
In contrast to HTTP / 2, HTTP / 1.1 cannot reuse requests
-
Requests are made in large numbers under concurrent conditions, and we need to establish multiple HTTP / 1.1 connections and make requests in all of them. HTTP / 1.1 requests typically loop through multiple TCP connections, so connection level balancing comes into play