특정녀석이 일정한 시간만되면 CPU를 엄청 잡아먹어 타 서비스에 영향을 줄때…… 이럴때 사용하면 유용합니다. 은근 간단한 설정만으로 다목적으로 활용하기에 좋습니다.
또한 github를 통해 소스도 공개해두고 있으니 관심있으신분들은 한번 훑어보세요.
참고 : http://cpulimit.sourceforge.net/
https://github.com/opsengine/cpulimit
아래는 Ubuntu 14.04 에서 설치 및 사용하는 예제입니다.
RHEL/CentOS 에서는 yum으로 간단히 설치가능합니다.
# apt-get install cpulimit
:: PID 5564에 30% 사용률 제한 설정
PID별 사용률 제한과 동시에 load average 도 줄어드는게 확인될겁니다.
# cpulimit -p -l 30 &
좀더 자세한 옵션사용법은 help 참고
# cpulimit --help
CPUlimit version 2.0
Usage: cpulimit TARGET [OPTIONS...] [-- PROGRAM]
TARGET must be exactly one of these:
-p, --pid=N pid of the process
-e, --exe=FILE name of the executable program file
The -e option only works when cpulimit is run with admin rights.
-P, --path=PATH absolute path name of the executable program file
OPTIONS
-b --background run in background
-c --cpu=N override the detection of CPUs on the machine.
-l, --limit=N percentage of cpu allowed from 1 up.
Usually 1 - 400, but can be higher on multi-core CPUs (mandatory)
-k, --kill kill processes going over their limit instead of just throttling them.
-r, --restore Restore processes after they have been killed. Works with the -k flag.
-v, --verbose show control statistics
-z, --lazy exit if there is no suitable target process, or if it dies
This is the final CPUlimit option. All following options are for another program we will launch.
-h, --help display this help and exit







