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

feat: add memory limiter to gateway collector #1086

Merged
merged 9 commits into from
Mar 27, 2024

Conversation

blumamir
Copy link
Collaborator

No description provided.

@blumamir blumamir requested a review from a team as a code owner March 24, 2024 08:30
// confgiures the processor spike_limit_mib. When memory usage exceeds the hard limit minus this amount,
// the processor will enter memory limited mode and will start refusing data.
// as recommended by the processor docs, this is set to 20% of the hard limit
memoryLimiterSpikeLimitMiB = 90
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe worth considering defining these constants in a relative way like 0.2 * memoryLimiterLimitMib. This way we can define a single default memory size of requestMemory and calculate all the others based on that value.
That way we could add code that retries with a smaller requestMemory in case of failure to deploy (and all the other sizes will adjust)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @RonFed ,

I refactored the code so now it's configurable and relative. Can you please take a look again?

Copy link
Contributor

@rauno56 rauno56 left a comment

Choose a reason for hiding this comment

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

Do I understand correctly that the defaults are as percentages calculated, but when user wants to specify memory limits, they can only use absolute values?

The user cannot set the actual request limit on the gateway, because that will be overwritten by a value on OdigosConfiguration?


memoryLimiterSpikeLimitMiB := memoryLimiterLimitMib * defaultMemoryLimiterSpikePercentage / 100.0
if odigosConfig.Spec.CollectorGatewayMemoryLimiterSpikeLimitMiB != 0 {
memoryLimiterSpikeLimitMiB = odigosConfig.Spec.CollectorGatewayMemoryLimiterSpikeLimitMiB
Copy link
Collaborator

@RonFed RonFed Mar 25, 2024

Choose a reason for hiding this comment

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

Maybe worth adding a check here that memoryLimiterSpikeLimitMiB < memoryLimiterLimitMib?
Why are the configuration options used as absolute values and our defaults relative? I think we should be consistent with the relative approach

logger := log.FromContext(ctx)
desiredDeployment, err := getDesiredDeployment(dests, configData, gateway, scheme, imagePullSecrets, odigosVersion)
desiredDeployment, err := getDesiredDeployment(dests, configData, gateway, scheme, imagePullSecrets, odigosVersion, memConfig)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure how often it might happen, but if our default is to request 500MB, and there is some resource limit preventing us from doing so, we should probably have some handling for it.

@blumamir
Copy link
Collaborator Author

Do I understand correctly that the defaults are as percentages calculated, but when user wants to specify memory limits, they can only use absolute values?

The relative defaults allow a user to set just one value (the memory request) and have all the other values automatically derived from it.

If a user wants to set specific values, I thought it would be more straight forward to set the values as they would be written into the k8s manifest, instead of specifying relative amounts which requires more mental effort to calculate and understand. but I am open for change if you think it will be easier for users to use relative values @rauno56 @RonFed

@rauno56
Copy link
Contributor

rauno56 commented Mar 26, 2024

I get where you are coming from, but I was also a bit surprised with the difference there.

Both of you have piles more experience in this specific case so I'll let you to thumb wrestle this out, but as a unsuspecting user-developer I'd expect defaults to have the same "power" as user-set values.

It'll likely also help with the maintainability to have the terms, concepts and the logic match.

@blumamir blumamir merged commit 53591fc into odigos-io:main Mar 27, 2024
10 checks passed
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