How to Limit CPU Usage for a Service?
in Linux
Applies to:
Linux OS – OL7 and later
Linux x86-64
Question:
How to limit CPU usage by a service and make it persist across reboots.
Answer:
Solution 1:
Use the ‘systemctl set-property’ command. You can set the CPUQuota property within the systemd service unit file or using the command line as follows:
$ sudo systemctl set-property SERVICE_NAME.service CPUQuota=10%
NOTE: Replace SERVICE_NAME with the name of your service.
The above command will set the CPUQuota property for the specified service and restrict its CPU usage to 10%. The configuration will persist across reboots because it is applied to the systemd service unit file.
Tagged:
0