(Plesk for Linux) Cgroups Manager¶
A website on a shared hosting can consume all system resources and disrupt the performance of other websites. This issue is known as the “noisy neighbor problem”.
Plesk Cgroups Manager is an extension that helps you address this issue by managing the consumption of the CPU, RAM, disk read and write bandwidth.
For each system resource Cgroups Manager allows you to:
- Set a maximum amount (limit) on the consumed resource.
- Monitor the amount of the consumed resource and send email notifications when it exceeds a certain level (threshold).
You can configure Cgroups Manager and set the limit on the consumed resource on the following levels:
- For a service plan, affecting all subscriptions under the plan.
- For a single subscription.
Requirements¶
Plesk License¶
Cgroups manager is available for the following Plesk editions:
- Plesk Web Pro
- Plesk Web Host
If you are using the Web Admin plan and want to manage the resource consumption of your websites, consider upgrading to Web Pro and distributing websites among several subscriptions.
Limitations¶
- Cgroups Manager cannot limit the resources Plesk extensions and custom manually installed services consume. This is true for all Plesk extensions: LiteSpeed is no exception.
- Cgroups Manager in a Virtuozzo 7 container can manage RAM and the CPU, but not the disk I/O. Cgroups Manager in a Virtuozzo virtual machine does not have this limitation. To use Cgroups Manager without the limitation, migrate your Plesk from a Virtuozzo 7 container to another OS.
Installation¶
To enable the Cgroups Manager:
Install the component Resource Controller (Cgroups) using the Plesk Installer:
Go to Tools & Settings > Updates > Add/Remove Components.
Select the “Resource Controller (Cgroups)” and hit Continue.
Note
If the required component is missing from the list of available components, make sure that your system meets the requirements.
Start the component:
- Go to Tools & Settings
- Click the Services Management link
- Start the service “Resource Controller (Cgroups)”.
Configuring the Cgroups Manager¶
Caution
Incorrect configuration of Cgroups Manager can make hosted websites slower or even unavailable. Please make sure that you have read and understood the instructions in this topic before making any changes.
You can configure Cgroups Manager on the following levels:
- For a service plan, affecting all subscriptions under the plan.
- For a single subscription.
Settings on the subscription level override those on the service plan level. Add-on plans can not be used to modify the Cgroups Manager settings.
Once you install and start the service, the following configuration tools become available:
Tool | Service Plan | Subscription |
---|---|---|
Plesk Panel (use the Service Provider view) |
|
|
Plesk CLI | Use the -cgroups* options of the
service_plan
utility. |
Use the -cgroups* options of the
subscription_settings
utility. |
Plesk XML API | See the documentation on Managing Service Plans. | See the documentation on Managing Subscriptions. |
Limiting Resource Consumption¶
Setting up the Limits¶
The first of the settings available for each managed resource is the limit value. Each managed resource has its own limit value. By default, limit values are not set, that is, resources are not limited.
Subscriptions can share limit settings, but each has its own limit.
If a resource is limited for a given subscription:
- The Cgroups Manager monitors all processes owned by the subscription’s system user. Together these processes can consume no more than the limit value of each resource.
- If a subscription reaches its limit, the operating system performs a certain action, depending on the resource type.
- A subscription cannot exceed the limit even if free resources of the corresponding type are available on the server (idle CPU cycles, free RAM, etc.).
If a resource is not limited for a given subscription:
- A subscription’s processes can use as much of that resource as is available.
- The resource is shared between processes of all subscriptions:
- CPU time and disk I/O are shared almost equally.
- RAM is shared as requested by processes.
In both cases, there is no guarantee that a subscription will receive any minimal amount of resource.
Allowed Setting Values for Limits¶
The limit settings may have the following values:
Setting | Measured in | Available values |
---|---|---|
CPU limit | Percentage of CPU time, where 100% is one CPU core fully used | Not more than 100% * Number of CPU cores |
RAM limit | Bytes | Not less than 1MB |
Disk input (write) speed | Bytes per seconds | Not less than 1MB per second |
Disk output (read) speed | Bytes per seconds | Not less than 1MB per second |
If the server has multiple CPU cores, the available CPU amount is equal to 100% * the number of CPU cores. For example, if your server has four CPU cores, the available CPU amount is 400%.
How the System Manages Resource Consumption¶
When the processes of a particular subscription use the maximum allowed value of a resource, the operating system performs certain actions, depending on the resource type.
Resource Overused | Actions | Impact |
---|---|---|
CPU, disk read and write bandwidth | The system restricts the processes of this subscription to use no more resources than the limit allows. | The corresponding websites might operate more slowly and have a higher response time. |
RAM | When the processes of a particular subscription reach the RAM limit, the system kills the most memory-consuming one. | The corresponding website might be unavailable for some time and respond to requests with HTTP codes 5xx. |
Monitoring and Notifications for Resource Consumption¶
Setting up Monitoring and Notifications¶
Once you set the limit for a resource, you can also configure Plesk to monitor the consumption of that resource.
To turn monitoring on, set the following values:
- Threshold (“Notify when exceeded.” in Plesk Panel).
- Period.
To turn monitoring off, remove the corresponding threshold value.
Allowed Setting Values for Monitoring¶
The monitoring settings may have the following values:
Setting | Measured in | Available values |
---|---|---|
CPU limit | Percentage of CPU time, where 100% is one CPU core fully used | Not more than the CPU limit value |
RAM limit | Bytes | Not less than 1MB and not more than the RAM limit value |
Disk input (write) speed | Bytes per seconds | Not less than 1MB per second and not more than the disk write limit value |
Disk output (read) speed | Bytes per seconds | Not less than 1MB per second and not more than the disk read limit value |
Check Period (for any resource) | Seconds | 300 (5 minutes), 3600 (1 hour), or 86400 (24 hours) |
How the System Performs Monitoring¶
When you enable resource monitoring for one or more resources, the Cgroups Manager starts monitoring their consumption. If you enabled resource monitoring on the subscription level, resource usage for that subscription will be monitored. If you enabled resource monitoring on the service plan level, resource usage for all subscriptions based on that service plan will be monitored instead:
- Every five minutes the Cgroups Manager counts the average resource
consumption of a subscription and checks whether it is equal or
greater than the
threshold
. - After every
period
the Cgroups Manager checks how many times the subscription has exceeded thethreshold
within the lastperiod
of time.- If the subscription has exceeded the
threshold
in all intervals of aperiod
, Cgroups Manager sends an email notification. - If this happens for longer than one
period
, no extra notifications are sent.
- If the subscription has exceeded the
An Example of Monitoring¶
This example will help you better understand how the Cgroups Manager performs monitoring and triggers notifications.
There is a subscription plan P with the following settings:
Setting | Value |
---|---|
CPU Limit | 200% |
CPU Threshold | 160% |
CPU Check Period | 1 hour |
As explained before, 100% means one CPU core is fully used.
There are two subscriptions under the plan: A and B.
Subscription A has a CPU-heavy task which runs each hour and takes about 10 minutes. For those 10 minutes, the subscription’s processes consume more than 160% of CPU time. At other times, the subscription consumes less than 160% of CPU time. It does not matter for notifications whether it reaches the limit value.
The website of Subscription B is under heavy load. The subscription’s processes always consume more than 160% of CPU time.
Cgroups Manager counts the average consumption for each 5-minute interval. Then, at the end of an hour it has the following results:
- Subscription A has exceeded the threshold in two intervals of 12. Cgroups Manager will not send any notifications.
- Subscription B has exceeded the threshold in all 12 intervals. Cgroups Manager will send a notification, but will not repeat it if the load continues.
Recipients and Content of the Notifications¶
To select who will receive the notifications:
- Go to Tools & Settings > Notifications.
- Select the required recipients next to the CPU, RAM, and Disk I/O (Cgroups).
The content of each notification message is built from a template. To read and edit the template:
- Go to Tools & Settings > Notifications.
- Click the rightmost button next to the CPU, RAM, and Disk I/O (Cgroups).
For more information, read the documentation on the automatic email notifications.
Integrating Cgroups Manager with the Monitoring Extension¶
You can integrate Cgroups Manager with the Monitoring Extension. This enables customers to see how much resources their subscriptions consume, and also enables the Plesk administrator to see and compare resource usage between up to ten subscriptions.
Learn how to integrate Cgroups Manager with the Monitoring Extension.
Restrictions¶
Some technical and business issues can not be resolved with resource management:
- Customers who overused resources earlier will probably experience worse performance.
- Cgroups Manager does not account and limit resources for Ruby, Python, and Node.js web-applications using the Phusion Passenger.