Limit service memory and CPU

Set cgroup limits without editing the unit file

systemctl set-property myapp.service MemoryMax=512M CPUQuota=50%

tool
systemd26 commands
tags
systemdperformance

More systemd commands

  • systemctl status myapp.service | grep -E 'Memory:|CPU:|Tasks:'

    Current memory, CPU time and task count from the cgroup

  • systemctl list-units --type=socket --all

    Show all socket units and their state, including inactive ones

  • systemctl mask snapd.service

    Stop a service from being started by anything, even as a dependency

  • systemctl show myapp.service -p Environment

    Print the environment variables set for the service

  • systemd-analyze critical-chain <unit>

    Show the chain of units that really delays boot; more honest than blame

all 26 systemd commands