Support setting ballast size in percentage of total Mem in ballast extension#3456
Conversation
|
@mxiamxia can you fix these failing tests. Thx. |
|
@Aneurysm9 @anuraaga could you please take a look? |
|
@anuraaga @Aneurysm9 can you please re-review? The tests are now passing. |
…upported for containers and physical hosts
|
Hi @anuraaga @bogdandrutu @tigrannajaryan @rakyll , PTAL! Thanks. |
bogdandrutu
left a comment
There was a problem hiding this comment.
@tigrannajaryan @rakyll PTAL, will merge tomorrow otherwise
tigrannajaryan
left a comment
There was a problem hiding this comment.
LGTM, except I have just found we also have a built-in ballast implementation in
opentelemetry-collector/service/collector.go
Line 317 in 6cafee9
I am confused. Why do we have 2 implementations? Are they related or competing?
This old one is taking the |
|
@bogdandrutu this PR is ready to be merged. :-) |
Descritpion:
Enhance the current ballast extension which is to set memory ballast for the collector process. And we'll remove
--mem-ballast-size-mibsupport from command line later.The changes,
Added new configuration
size_in_percentagewhich can dynamically set ballast size based on the total memory of the running environments. (hosts, Docker, K8s, etc)Sample Config,
How ballast size is calculated by percentage setup
When
size_in_percentageis enabled with the value(1-100), theballast_sizewill be calculated bysize_in_percentage * totalMemory. ThetotalMemorywill be calculated for hosts and containers(in docker, k8s, etc) by the following steps,Look up Memory Cgroup subsystem where the collector is running on(it could be container, VM or bare metal host), check if there is total memory limitation has been set for the collector process.
The total assigned memory for the process is in
memory.limit_in_bytesfile under cgroup (eg,/sys/fs/cgroup/memory/memory.limit_in_bytes).If
memory.limit_in_byteshas a positive value other than9223372036854771712. Theballest_sizewill be calculated by
memory.limit_in_bytes * size_in_percentage. Else Ifmemory.limit_in_bytesvalue is9223372036854771712(0x7FFFFFFFFFFFF000), it indicates there is no memory limit has been set for the collector process in cgroup. Then thetotalMemoerywill be determined in the next stepif there is no memory limit set in cgroup for the collector process or container where the collector is running. The total memory will be calculated by
github.com/shirou/gopsutil/memwhich is supported in multiple OS systems.Link to tracking Issue:
#2516
Test:
Tested locally on EC2, Docker and K8S for
ballast_size_in_percentageconfiguration