Skip to content

Cluster lazy loading#2740

Closed
nt wants to merge 1 commit intoenvoyproxy:masterfrom
nt:lazy-load
Closed

Cluster lazy loading#2740
nt wants to merge 1 commit intoenvoyproxy:masterfrom
nt:lazy-load

Conversation

@nt
Copy link
Member

@nt nt commented Mar 6, 2018

Lazy loading

This PR addresses #2500 for cluster lazy loading. Key design points are:

  • Exposes a new LazyLoader type that is owned by cluster manager.
  • LazyLoader allows the user to request for a specific cluster config.
  • LazyLoader is only available is there is a dynamic CDS config.
  • It will own its own separate XDS stream to not interfere with ClusterManager.
  • Callbacks can be added to ClusterManager to be notified of clusters updates or removal.

Missing in this initial PR. guidance requested:

Risk Level: Medium (new feature)

Signed-off-by: Nicolas Thiebaud <nicothieb@google.com>
@nt
Copy link
Member Author

nt commented Mar 6, 2018

cc: @htuch

@nt
Copy link
Member Author

nt commented Mar 7, 2018

cc @mattklein123 for an initial review

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super excited to see this. Some comments to kick off the review.

public:
virtual ~ClusterUpdateCallbacks() {}

virtual void onClusterAddOrUpdate(const ThreadLocalCluster& cluster) PURE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs Doxygen comments (see rest of file for examples to mimic style).

virtual void addClusterUpdateCallbacks(ClusterUpdateCallbacks& callbacks) PURE;
virtual void removeClusterUpdateCallbacks(ClusterUpdateCallbacks& callbacks) PURE;

virtual LazyLoader* lazyLoader() const PURE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these need comments as above.


/**
* Lazy loading is only available when using CDS, bootstrap with static clusters will not support
* lazy loading.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true if we have independent lazy CDS config source in the bootstrap as in envoyproxy/data-plane-api#524?

public:
virtual ~LazyLoader() {}

virtual void loadCluster(const std::string& cluster) PURE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doxygenate.

*/
virtual bool addedViaApi() const PURE;

virtual bool addedLazily() const PURE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More so than my comment on envoyproxy/data-plane-api#524, I think this is where we might want to think about how to reconcile incremental and lazy loading. As a strawman, I'd suggest there is no difference between an incremental cluster addition on a regular CDS channel and a lazy loaded cluster. WDYT? @mattklein123 as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Ideally if we could extend the xDS API with incremental updates and incremental subscriptions (or hint) we could handle lazy loading with a single stream and reconcile quite a bit of this logic.

Has there been any work / discussion on this? Should I start a data-plane-api proposal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started a strawman proposal here: envoyproxy/data-plane-api#527

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to spend heads down time with this next week, but at a high level if we can handle lazy loading w/ incremental lets just do incremental. We will get much bigger bang for the buck here. I will focus mostly on helping work through the issues in envoyproxy/data-plane-api#527.

hdrs = ["cluster_manager_impl.h"],
srcs = [
"cluster_manager_impl.cc",
"lazy_loader_impl.cc",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to have lazy_loader_impl.* in their own lazy_load_lib target to keep fine grained dependencies for testing.

std::unique_ptr<Config::Subscription<envoy::api::v2::Cluster>> subscription_;
Event::Dispatcher& primary_dispatcher_;
ClusterManagerImpl& cluster_manager_;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: superfluous blank space.

Event::Dispatcher& primary_dispatcher,
Runtime::RandomGenerator& random,
ClusterManagerImpl& cluster_manager,
Stats::Store& statsconst);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: s/statsconst/stats.

};

void LazyLoaderImpl::loadCluster(const std::string& cluster) {
subscription_->updateResources({cluster});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit strange use of the API for the subscription. Semantically, updateResources is saying "we now have a new set of resources we care about from this point forward". You want to say "send me an update for only this resource and forget about it when we're done". Or.. do we?

What should the behavior be for a lazy loaded cluster when it is modified at the management server? Do we want to have it pushed asynchronously? What are the plans for removal of clusters when they go away on the management server?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be solved using a single stream for the cds impl and the lazy loader if we extended the xds api to do incremental. See my comment here #2740 (comment)

cluster_manager_(cm) {
ASSERT(bootstrap.dynamic_resources().has_cds_config());
if (bootstrap.dynamic_resources().has_ads_config()) {
// Create an ADS stream for the lazy loader. We can not reuse the cluster manager ADS stream.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is what we want for ADS. This will become clearer once we resolve envoyproxy/data-plane-api#524.

@htuch
Copy link
Member

htuch commented Mar 16, 2018

I'm going to close this out while we work on design. @nt is upstreaming individual PRs that are extracted from this.

@htuch htuch closed this Mar 16, 2018
@nt nt deleted the lazy-load branch July 22, 2019 21:21
Shikugawa pushed a commit to Shikugawa/envoy that referenced this pull request Mar 28, 2020
Signed-off-by: Kuat Yessenov <kuat@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants