Limit CPU and memory usage for PHP-FPM and Nginx processes in CentOS

7,773

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:
7,773

Related videos on Youtube

KK Patel
Author by

KK Patel

Cloud Infrastructure and DevOps Expert with around decade experience in IT Infrastructure. Expert in Designing and building Infrastructure as code, automation of cloud infrastructure provisioning , system provisioning , apps/Micro services deployments , CI/CD pipelines , building highly available and reliable IT Infrastructure platforms.

Updated on September 18, 2022

Comments

  • KK Patel
    KK Patel almost 2 years

    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 ?