How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

How to Install and Use CPULimit on CentOS 7

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
22
VIEWS
Share on FacebookShare on Twitter

Contents

  1. How does it work?
  2. Prerequisites
  3. Installing CPULimit
  4. Configuring CPULimit with an application
  5. Uninstalling CPULimit
  6. Want to contribute?


CPULimit is a Linux utility offered to limit an application’s resource usage. It is useful when you want to prevent a single application from slowing down other applications; or stop an application from using an entire core or cores for an extended period of time.

Having said that, CPULimit may not work with all applications as it (essentially) starts/stops processes at intervals to bring the CPU usage (expressed as an average) down. This will be explained in the next section.

How does it work?

CPULimit is not designed to work with applications that, for example, use job control; as they may be killed when CPULimit sends a stop (SIGSTOP) signal. In essence, applications will be turned on/off rapidly in order to limit a program to a desired number of cycles.

Don’t worry though – most applications will work. Some applications that can be limited include PHP, Java, and Nginx.

Prerequisites

In order to install CPULimit successfully, you will need:

  • A server running CentOS 7 (64-bit systems only).
  • make, screen and wget.
  • Root access or sudo privileges.

Installing CPULimit

Assuming you have all the prerequisites installed, you should be able to breeze through the installation process. To begin, you will need to download CPULimit and extract the tarball:

cd ~
wget https://astuteinternet.dl.sourceforge.net/project/limitcpu/limitcpu/cpulimit-2.5.tar.gz
tar -xvf cpulimit-2.5.tar.gz

Once the tarball finishes extracting, we can enter the newly created directory and begin compiling CPULimit:

cd cpulimit-2.5

Now, run make to begin compiling CPULimit into a binary:

make

Once this process completes, you will have a binary in the cpulimit-2.5 directory. In order to make it available system-wide, we will need to perform the command below:

make install

It may take some time to complete.

Configuring CPULimit with an application

In order to use CPULimit, we’ll need to know the process ID. This is known as the PID. By using top we can see a list of our processes:

top -c

You will see a list of processes and it should look like the following:

Tasks: 130 total,   1 running, 129 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.2 us,  0.0 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3881740 total,   191952 free,   413472 used,  3276316 buff/cache
KiB Swap:  4063228 total,  4062912 free,      316 used.  2881364 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1336 plex      35  15 1368172  67464   6668 S   0.3  1.7 155:41.58 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-995f1dead+
31345 root      20   0  326572  21844  12784 S   0.3  0.6  86:45.32 docker-containerd --config  /var/run/docker/containerd/containerd.toml
    1 root      20   0  193704   6744   4088 S   0.0  0.2   6:49.22 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
    2 root      20   0       0      0      0 S   0.0  0.0   0:01.45 [kthreadd]
    3 root      20   0       0      0      0 S   0.0  0.0   0:12.77 [ksoftirqd/0]
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 [kworker/0:0H]
    7 root      rt   0       0      0      0 S   0.0  0.0   0:13.95 [migration/0]

If we wanted to limit plex, for example, we would need to take note of the PID. In this case, it is 1336. If we want to limit plex to 15% of the CPU, we need to create a screen and execute cpulimit:

screen -S limitcpu
cpulimit -p 1336 -l 15

To exit the screen, use the following combination: CTRL + A + D. To enter the screen once you exit, simply execute the following:

screen -r limitcpu

The general format to run cpulimit will be below:

cpulimit -p (PROCESS PID) -l (CPU %)

Note: PROCESS PID is the process ID and CPU % is the CPU limit.

Uninstalling CPULimit

Removing CPULimit is simple. Perform the following commands:

cd ~/cpulimit-2.5
make deinstall

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Install BoltWire CMS on CentOS 7
CentOS

How to Install BoltWire CMS on CentOS 7

February 14, 2020
Showterm.io – A Terminal/Shell Recording, Upload and Share Tool for Linux
CentOS

Setup HTTP Authentication With Nginx on CentOS 7

February 14, 2020
Next Post

How to Install Crate.IO on CentOS 7

Install ImageMagick on CentOS 6

Setup Timezone and NTP on CentOS 6

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

Install Nginx with Ngx_pagespeed on CentOS 7

3 years ago

Setup Nginx-RTMP on CentOS 7

3 years ago

How To Setup Two-Factor Authentication (2FA) for SSH on CentOS 6 using Google Authenticator

3 years ago

How to Run Multiple Commands on Multiple Linux Servers

4 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.