ballastextension

package
Version: v0.40.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

Memory Ballast

Memory Ballast extension enables applications to configure memory ballast for the process. For more details see:

The following settings can be configured:

  • size_mib (default = 0, disabled): Is the memory ballast size, in MiB. Takes higher priority than size_in_percentage if both are specified at the same time.
  • size_in_percentage (default = 0, disabled): Set the memory ballast based on the total memory in percentage, value range is 1-100. It is supported in both containerized(eg, docker, k8s) and physical host environments.

How ballast size is calculated with percentage configuration When size_in_percentage is enabled with the value(1-100), the absolute ballast_size will be calculated by size_in_percentage * totalMemory / 100. The totalMemory can be retrieved for hosts and containers(in docker, k8s, etc) by the following steps,

  1. Look up Memory Cgroup subsystem on the target host or container, find out if there is any total memory limitation has been set for the running collector process. Check the value in memory.limit_in_bytes file under cgroup memory files (eg, /sys/fs/cgroup/memory/memory.limit_in_bytes).

  2. If memory.limit_in_bytes is positive value other than 9223372036854771712(0x7FFFFFFFFFFFF000). The ballest_size will be calculated by memory.limit_in_bytes * size_in_percentage / 100. If memory.limit_in_bytes value is 9223372036854771712(0x7FFFFFFFFFFFF000), it indicates there is no memory limit has been set for the collector process or the running container in cgroup. Then the totalMemory will be determined in next step.

  3. if 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/v3/mem[link] on mem.VirtualMemory().total which is supported in multiple OS systems.

Example: Config that uses 64 Mib of memory for the ballast:

extensions:
  memory_ballast:
    size_mib: 64

Config that uses 20% of the total memory for the ballast:

extensions:
  memory_ballast:
    size_in_percentage: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() component.ExtensionFactory

NewFactory creates a factory for FluentBit extension.

Types

type Config

type Config struct {
	config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct

	// SizeMiB is the size, in MiB, of the memory ballast
	// to be created for this process.
	SizeMiB uint64 `mapstructure:"size_mib"`

	// SizeInPercentage is the maximum amount of memory ballast, in %, targeted to be
	// allocated. The fixed memory settings SizeMiB has a higher precedence.
	SizeInPercentage uint64 `mapstructure:"size_in_percentage"`
}

Config has the configuration for the ballast extension.

func (*Config) Validate added in v0.30.0

func (cfg *Config) Validate() error

Validate checks if the extension configuration is valid

type MemoryBallast added in v0.31.0

type MemoryBallast struct {
	// contains filtered or unexported fields
}

func (*MemoryBallast) GetBallastSize added in v0.31.0

func (m *MemoryBallast) GetBallastSize() uint64

GetBallastSize returns the current ballast memory setting in bytes

func (*MemoryBallast) Shutdown added in v0.31.0

func (m *MemoryBallast) Shutdown(_ context.Context) error

func (*MemoryBallast) Start added in v0.31.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL