Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to limit CPU and memory usage for PHP-FPM and Nginx processes in CentOS. I came across following tools

  • cpulimit
  • cggroups
  • memory resource locater

which will more efficient and how can I configure for limiting resources for PHP-FPM and Nginx processes ?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I think "cpulimit" is best way to control cpu usage per process. cpulimit does not act on the nice value or other scheduling priority stuff, but on the real cpu usage.

cpulimit

Install cpulimit on Linux:

yum install cpulimit

To limit CPU usage of the process called nginx to 40%, enter:

cpulimit -e nginx -l 40

To limit CPU usage of the process to 40% by using its PID, enter:

cpulimit -p 3302 -l 40

Where,

-p : Process PID. -e : Process name. -l : percentage of CPU allowed from 0 to 100. -P: absolute path name of the executable program file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.