CyberPanel v2.1.1 introduced a feature to enforce website disk limits via packages.
While creating any new package you can see a check on the package creation page called Enforce Disk Limits. If you check this option, all websites under this package will not be able to use disk more then what it is specified in Disk Space box.
For example, we want to set a 10GB space limit on the new website first of all you need to create a package from the Package->Create Package set the space to 10GB, and check the Enforce Disk Limits to make sure they can't exceed or use more then 10GB of space.
For older CyberPanel with existing websites can also set disk limits by turning on this option for existing packages.
Go to List Websites page to find out which package is being used by the site.
Now go to the modify package page and select that package and then check the Enforce Disk Limits option.
To use this feature your CyberPanel version must be v2.1.1 or above.
Before reading this document you must read:
Once limits are applied, resource usage monitoring becomes important. You can view resource usage for any website at https://IP Of Your Server:8090/container/example.com
.
We will put stress on CPU, Memory and see how limits behave during the stress.
Run ls -la /home and find user of your website. Read the website limits document and grant 10% CPU usage to the website.
Now add your website user to the wheel group (usermod -aG wheel user) so it can run commands via sudo. (Don't do this on a production node)
Install a stress testing tool
yum install stress -y
And then run this command to generate high CPU Load
sudo -u <website user> stress -c 3 -i 1 -m 1 --vm-bytes 128M -t 20s
Replace website user in the above command. Now before the limits are applied, your CPU usage should look something like this during the stress period.
As you can see currently limits are not applied, so the website user was able to use 100% of CPU. We will now enforce 10% of CPU usage and see the output.
First run the command below without any limits being applied.
sudo -u <website user> stress -c 2 -i 1 -m 1 --vm-bytes 128M -t 20s
Output should be something like
Now apply 30MB of ram limit and run the same command:
Before limits are applied average memory usage was 110MB for the same command, after limits it could not exceed 30MB limit that we've applied.
Before reading this document you must read:
To apply limits navigate to https://IP Of Your Server:8090/container/
. Once there click launch, so that you can manage limits for the site. Click Edit to set the limits. You will see default limits but they are not currently applied.
You can apply 4 type of limits, and they are explained below.
CPU Percentage
Amount of CPU a certain website/user can use. On a Multi-core system user will get assigned share on each CPU Core. But CPU usage calculation will be divided by total cores on system. For example if website is assigned 10% CPU on a 4 core system, they will get 10% share of each CPU core.
If website start using 10% CPU on all 4 cores the average usage will then be 10% (40 / 4 = 10%)
Memory
Memory usage specifies the amount of RAM the website can use. User processes may be killed by kernel if they try to allocate more ram.
I/O
Disk I/O speed allowed for the website such as 10MB/s. This limit is not the same as IOPS described below.
IOPS
IOPS is different compared to IO, this specifies number of IO operations that a website user can do per second.
Network Speed
This specifies upload/download speed of the website user.
Containerization feature (v1.8.0 and above required, currently only CentOS is supported) offers to limit website resources and have no link to our Docker Manager feature. With containerization you can limit various system resources for a website, cgroups are used on the back end to enforce these limits. You can limit:
These limits are applied to all processes forked under a website user (Such as lsphp processes). You can use ls -la /home command to find out user of each website. LiteSpeed Webserver forks php processes for sites using these Linux user accounts. If there are no limits applied a single tenant can use all available resources on your system.