karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.14k stars 813 forks source link

Clarification on caching mechanism in search and proxy components #4900

Open seanlaii opened 1 week ago

seanlaii commented 1 week ago

Please provide an in-depth description of the question you have: In the current Karmada search component, there are two sub-components: search and proxy. Both sub-components cache the resources defined in the ResourceRegistry.

My question is: Do these two sub-components use the same cache, or do they maintain separate caches for storing data?

The reason I'm asking is that currently, both sub-components are controlled through the resource registry. I only want to use the proxy functionality to read pod logs, and I don't need to use the search/cache functionality to cache pods. If these two sub-components create separate caches, it could potentially lead to resource wastage.

From reviewing the source code, my current understanding is that the search component's cache is managed through the InformerManager, while the proxy component has a MultiClusterCache for managing its cache.

If possible, I would also appreciate an explanation of the differences between these two caching mechanisms (InformerManager vs MultiClusterCache) and their respective use cases.

Thank you for your clarification on this matter.

Environment:

XiShanYongYe-Chang commented 1 week ago

My question is: Do these two sub-components use the same cache, or do they maintain separate caches for storing data?

They use two sets of caches.

For Search, the informer is directly used to build cache. For Proxy, it is equivalent to self-built cache. See proposal for reference: https://github.com/karmada-io/karmada/tree/master/docs/proposals/resource-aggregation-proxy

XiShanYongYe-Chang commented 1 week ago

You can disable the search capability by setting the component parameter disable-search.

seanlaii commented 1 week ago

Got it. Thanks for the information!