xdsclient: reduce the number of ADS requests #7473
Labels
Area: xDS
Includes everything xDS related, including LB policies used with xDS.
Type: Feature
New features or improvements in behavior
The xDS client watch API looks like this:
grpc-go/xds/internal/xdsclient/client.go
Line 47 in 6fa393c
This means that if a user of the API wants to register watches on
N
resources, it has to invoke the APIN
times. This is a common scenario in many use-cases (examples include xDS resolver, CDS LB policy, xDS enabled gRPC server etc).The watch API implementation inside the xDS client delegates the watch to the appropriate authority here:
grpc-go/xds/internal/xdsclient/authority.go
Line 458 in 6fa393c
This results in the
authority
asking the underlying transport to send the request out:grpc-go/xds/internal/xdsclient/authority.go
Line 593 in 6fa393c
The implement in the
Transport
queues this request here:grpc-go/xds/internal/xdsclient/transport/transport.go
Line 258 in 6fa393c
This is eventually processed by the
send
goroutine and the request is sent out on the wire:grpc-go/xds/internal/xdsclient/transport/transport.go
Line 362 in 6fa393c
So, if we have a case where an entity watching an LDS resource receives a response that contains
N
RDS resources, it will end up makingN
watch API calls, one for each resource, and this will eventually result inN
requests on the ADS stream. Each of these requests will contain one more resource compared to the previous one. The situation can be worsened in the case where the LDS resource pointed toK
RDS resources and was changed to point toN
new RDS resources. So, this would end up inK+N
requests on the ADS stream.While this behavior is suboptimal, it needs to be noted that:
There are a few things we can try to make this better though:
authority
andtransport
packages. With this approach:authority
sending the list of resources to thetransport
to send out, it will simply send a message to thetransport
saying something needs to be sent out.authority
already maintains a list of resources requested by watcherstransport
already maintains a list of resources sent out on the ADS stream, i.e requested from the servertransport
sees the message from theauthority
, it will query theauthority
to get the most recent list of resources to send out. If the most recent list matches what the transport has already sent out, the operation will be a no-op.The text was updated successfully, but these errors were encountered: