Setting a blkio limit for a user #
-
using iotop
sudo iotop -o -
create 10GB file
dd if=/dev/zero of=afile bs=1M count=10000copy this file to the /dev/null
dd if=afile of=/dev/nullcheck iotop
-
limit read bandwidth ot only one MB per second
sudo systemctl set-property user-1001.slice BlockIOReadBandwidth="/dev/sda 1M" -
do a daemon-reload
sudo systemctl daemon-reload -
check cgroup filesystem
cat /sys/fs/cgroup/blkio/user.slice/user-1001.slice/blkio.throttle.read_bps_device 8:0 1000000the “8:0” represents the jamor and minor numbers of the /dev/sda device:
ls -l /dev/sda
Setting a blkio limit for a service #
sudo systemctl set-property apache2.service BlockIOReadBandwidth="/dev/sda 1M"
When you set this property on the command line, you had to surround the /dev/sda 1M part with a pair fo double quotes. When you set this in a service file, you do not surround the /dev/sda 1M within double quotes.
Links #
man systemd.resource-control