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

add blog post for gomemlimit #158

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

add blog post for gomemlimit #158

wants to merge 2 commits into from

Conversation

blumamir
Copy link
Collaborator

No description provided.

Copy link
Contributor

@edeNFed edeNFed left a comment

Choose a reason for hiding this comment

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

Looks great, I would try to make it 30% shorter and little less ChatGPTy but its great as it anyway


Efficient memory and CPU management in Go applications involves a delicate balance, particularly around garbage collection (GC).

- Running Garbage Collection in Go is a blocking operation, and is considered relatively expensive (resource wise).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Running Garbage Collection in Go is a blocking operation, and is considered relatively expensive (resource wise).
- Running Garbage Collection in Go is a blocking operation, and is considered relatively expensive (CPU wise).

tags: [golang, resource-management]
authorImage: '/amir.jpg'
author: Amir Blum
metadata: GOMEMLIMIT, CPU consumption, resource management
Copy link
Contributor

Choose a reason for hiding this comment

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

I think SEO wise worth to add Otel, Opentelemetry, Opentelemetry collectors, collectors etc

markdown/docs/gomemlimit.mdx Outdated Show resolved Hide resolved

Key Trade-Offs:

- **Memory Reservation** - ensure your platform (e.g., Kubernetes) reserves a guaranteed amount of memory for your application. Without this, an OOM Kill event could occur unpredictably, undermining stability regardless of the GOMEMLIMIT value.
Copy link
Contributor

Choose a reason for hiding this comment

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

if you started with e.g Kubernetes
maybe after guaranteed amount of memory for your application. (e.g resource request)

- Memory not tracked by GOMEMLIMIT (e.g., stack memory, code memory).
- A buffer to accommodate GC delays when memory usage crosses the limit.
- safety margin.
- **Low vs High GOMEMLIMIT**:
Copy link
Contributor

Choose a reason for hiding this comment

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

the low vs high is not so clear in my opinion,
maby stability versus prioritizing busniess logic?
even though is sounds a duplicate for key considerations above

In our setup, we followed the [OpenTelemetry memory limiter processor best practices](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/memorylimiterprocessor#best-practices):

- We reduced 50MB from the memory request in Kubernetes and assumed this is roughly the memory allocated to the heap.
- We used 80% of the remaining memory as the GOMEMLIMIT value (leaving 20% of the assumed heap memory as a buffer).
Copy link
Contributor

Choose a reason for hiding this comment

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

20% is the 50MB that reduced right? in the first point u talk in MB and second in precentage maybe worth refactor this two sentences

- **Lower Value** - Provides greater stability by allocating more memory headroom, reducing the risk of crashes.
- **Higher Value** - Improves memory efficiency by prioritizing business logic over safety margins, but increases the risk of hitting OOM under load.

In our setup, we followed the [OpenTelemetry memory limiter processor best practices](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/memorylimiterprocessor#best-practices):
Copy link
Contributor

Choose a reason for hiding this comment

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

It is the first time Opentelemetry is mention, in general seems like we hook our use case without context. maybe worth adding another section of our case after the general explanations about GOMEMLIMIT?

@@ -0,0 +1,205 @@
---
pubDate: 'Dec 17 2024'
title: 'Understanding GOMEMLIMIT: How It Can Spike CPU Usage (and How to Fix It)'
Copy link
Contributor

Choose a reason for hiding this comment

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

What about:
Understanding GOMEMLIMIT: Lessons Learned from Optimizing OpenTelemetry Collectors

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.

4 participants