Example
[!IMPORTANT]
This is an example and is NOT covered by semver compatibility guarantees.
If PORT
env variable is specified and is a valid port, a simple http server
is started on that port, listening on all available interfaces. Alternatively,
-listen
flag can be used to specify listening address. If both are not specified,
then container simply prints GOMAXPROCS
and GOMEMLIMIT
values and some runtime/platform
data to stdout and exits.
Docker
Example docker images are only provided for limited number of platforms/architectures.
As examples are not covered by semver compatibility guarantees, semver tagged images are
not provided. However, images are tagged with both short and full commit hashes to test
a specific commit. latest
tag corresponds to HEAD
of the default branch.
SLSA build level 3 provenance is attached to the images. This project
also provides GitHub native provenance
for images, though only at SLSA build level 2, due to isolation requirements.
docker run --rm --cpus=1.5 --memory=250M ghcr.io/tprasadtp/go-autotune
Docker (Linux)
Docker (Windows)
[!IMPORTANT]
Example docker images are only provided for Server 2019, Server 2022 and
Server 2025 because of Windows container version compatibility.
Systemd
-
Clone this repository.
git clone --depth=1 https://github.com/tprasadtp/go-autotune
-
Checkout the repository.
cd go-autotune
-
Build the example binary and install it to ~/.local/bin
as "go-autotune".
go build -trimpath \
-ldflags='-w -s' \
-tags=osusergo,netgo \
-o ~/.local/bin/go-autotune \
github.com/tprasadtp/go-autotune/example
-
Verify that CPU and memory controllers are available for user level units.
If output does not contain strings cpu
and memory
, CPU controllers are not available for
user level units. Install the binary to a root accessible location (like /usr/local/bin
)
and run the systemd-run
commands without the --user
flag.
systemctl show user@$(id -u).service -P DelegateControllers
-
Run the example binary as a transient unit with with resource limits applied.
systemd-run -Pq --user -p "CPUQuota=150%" -p MemoryHigh=250M -p MemoryMax=300M go-autotune