Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ReplicaSet and Job metadata generators to use partial meta objects #109

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

swiatekm
Copy link
Contributor

@swiatekm swiatekm commented Sep 27, 2024

We only use metadata from Jobs and ReplicaSets, but require that full resources are supplied. This change relaxes this requirement, allowing PartialObjectMetadata resources to be used. This allows callers to use metadata informers and avoid having to receive and deserialize non-metadata updates from the API Server.

See elastic/elastic-agent#5580 for an example of how this could be used. I'm planning to add the metadata informer from that PR to this library as well. Together, these will allow us to greatly reduce memory used for processing and storing ReplicaSets and Jobs in beats and elastic-agent.

This is will help elastic/elastic-agent#5580 and elastic/elastic-agent#4729 specifically, and elastic/elastic-agent#3801 in general.

@swiatekm swiatekm requested a review from a team as a code owner September 27, 2024 13:46
@swiatekm swiatekm force-pushed the feat/k8s-job-replicaset-meta branch 2 times, most recently from 088bf6d to b910b89 Compare September 27, 2024 15:05
@ycombinator ycombinator removed the request for review from VihasMakwana September 27, 2024 20:39
@ycombinator ycombinator added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Sep 27, 2024
Copy link

@pkoutsovasilis pkoutsovasilis left a comment

Choose a reason for hiding this comment

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

LGTM! eager to see the impact of using PartialObjectMetadata on the mem footprint

We only use metadata from Jobs and ReplicaSets, but require that full
resources are supplied. This change relaxes this requirement, allowing
PartialObjectMetadata resources to be used. This allows callers to use
metadata informers and avoid having to receive and serialize
non-metadata updates from the API Server.
@swiatekm swiatekm force-pushed the feat/k8s-job-replicaset-meta branch from b910b89 to 30ded63 Compare October 2, 2024 12:45
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@swiatekm swiatekm requested a review from mauri870 October 2, 2024 13:17
@swiatekm swiatekm merged commit 70c0872 into main Oct 3, 2024
3 checks passed
@swiatekm swiatekm deleted the feat/k8s-job-replicaset-meta branch October 3, 2024 09:38
@ycombinator
Copy link
Contributor

LGTM! eager to see the impact of using PartialObjectMetadata on the mem footprint

@swiatekm Is there some way for you to quantify this impact (before vs. after), perhaps as a function of the number of ReplicaSets and Jobs?

@swiatekm
Copy link
Contributor Author

swiatekm commented Oct 4, 2024

LGTM! eager to see the impact of using PartialObjectMetadata on the mem footprint

@swiatekm Is there some way for you to quantify this impact (before vs. after), perhaps as a function of the number of ReplicaSets and Jobs?

Hard to do so in general, because the size of the resource in memory can heavily depend on user-provided metadata. For example, it's possible to set multiple annotations of up to 256kb each on it. In a test cluster I saw agent use 80% less memory on ReplicaSets specifically, but in real production clusters I'd expect the gains to be more substantial.

If we're talking about the total agent memory consumption, then that obviously depends on what inputs are enabled, but with the standalone Kubernetes manifest we provide, in a test cluster of 3 Nodes, with ~7500 ReplicaSets, I saw a reduction of ~120 Mb. You can see more details here: elastic/elastic-agent#5623.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants