limit systemd services with control group ( slice )
This document (000019590) is provided subject to the disclaimer at the end of this document.
SUSE Linux Enterprise Server 12
SUSE Linux Enterprise Desktop 12
From time to time it may be desirable to control a group of services, to improve control or system stability.
This is a control group, which may apply limits that affect all processes in this slice / control group.
In this example the docker service will be used to create a slice called docker.slice.
The values in this example are for illustration purposes only, and should not be not used in any production environment.
systemctl edit docker.slice [Unit] Description=Docker Slice Before=slices.target [Slice] MemoryAccounting=true MemoryLimit=2048M CPUAccounting=true CPUQuota=25% TasksMax=4096 systemctl edit --full docker.service
and add in the [Service] section:
After changing systemd config files a reload of the daemon is required:
Prepare the docker service for start:
systemctl enable docker systemctl start docker
To check, if the service is in the correct control group run:
systemd-cgls : ... ├─docker.slice │ └─docker.service │ ├─1298 /usr/bin/dockerd --add-runtime oci=/usr/sbin/docker-runc │ └─1383 docker-containerd --config /var/run/docker/containerd/containerd.toml --log-level warn ...
A word of caution:
The limits of the slice take precedence over limits configured in the service file.
Even "systemctl show SERVICE" will still show values configured in the service file or in /etc/systemd/system.conf , though no longer being effective anymore.
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000019590
- Creation Date: 28-Oct-2020
- Modified Date:28-Oct-2020
- SUSE Linux Enterprise Server
- SUSE Linux Enterprise Server for SAP Applications
For questions or concerns with the SUSE Knowledgebase please contact: firstname.lastname@example.org