How to Use Cgroups in Control Web Panel (CWP) to Limit User Resource Usage

0 1 hour ago

If you manage multiple hosting accounts on a single server, a single abusive user can easily consume all your CPU, RAM, or disk I/O — slowing down or even crashing other websites. Thankfully, Control Web Panel (CWP) includes built-in support for Cgroups, a powerful Linux kernel feature that lets you limit and control resource usage per user.

In this guide, you’ll learn how to enable, configure, and apply Cgroups in CWP to keep your server stable and your hosting environment fair.


🧠 What Are Cgroups?

Cgroups (Control Groups) are a Linux feature that allows system administrators to:

  • Limit CPU and RAM usage
  • Control disk I/O speed
  • Isolate heavy processes
  • Monitor resource consumption per user or group

CWP Pro integrates this into the panel so you can apply limits per hosting account with just a few clicks.


✅ Benefits of Using Cgroups in CWP

  • Prevent a single user from hogging CPU or RAM
  • Guarantee fair usage for all accounts
  • Keep high-traffic or buggy sites from affecting others
  • Enforce resource plans like shared hosting tiers

🔧 Step-by-Step: Enabling & Using Cgroups in CWP


🔹 Step 1: Enable Cgroups in CWP

  1. Log into CWP Admin
  2. Go to:
    System → Cgroups
  3. Click Enable Cgroups

If you get an error like “Cgroups not supported”, check that your kernel supports it (v1 is required) and ensure cgroup modules are loaded.


🔹 Step 2: Create a Cgroup Resource Plan

Go to:
System → Cgroups → Add New Plan

Set the following:

  • Plan Name: basic_2cpu_512mb
  • CPU Limit: e.g., 20 (for 20% of 1 core)
  • RAM Limit (MB): 512
  • Disk I/O:
    • Read (KB/s): 2048 (2 MB/s)
    • Write (KB/s): 1024 (1 MB/s)

You can also enter 51200 (50 MB/s) for high-performance plans.

Click Save Plan.


🔹 Step 3: Assign Plan to a User

  1. Go to:
    User Accounts → List Accounts
  2. In the Cgroups column, select your resource plan from the dropdown
  3. Click Apply

✅ That user is now isolated to the defined CPU, memory, and I/O limits.


📊 Recommended Limits Based on Hosting Tier

TierCPU (%)RAM (MB)Read KB/sWrite KB/s
Basic Shared10–20256–51220481024
Standard Plan25–4010244096–81922048
High-Traffic50–802048–40965120051200
Developer VPS100UnlimitedUnlimitedUnlimited

You can modify these depending on your server hardware (HDD vs SSD/NVMe).


🧪 Monitor Resource Usage

In System → Cgroups, you can view:

  • Current CPU % per user
  • RAM usage
  • Active I/O limits

You can also monitor system-wide behavior via:

top
htop
iotop

🔐 Pro Tips for Stable Hosting

  • Pair Cgroups with CSF + LFD for abuse protection
  • Use ModSecurity to prevent script-based overloads
  • Combine with PHP-FPM pools per user for better isolation

🧠 Cgroups vs Other Tools

ToolPurpose
CgroupsResource limiting per user
CSF/LFDFirewall, login failure daemon
ModSecurityApplication-level protection
PHP-FPM PoolsPer-user PHP resource tuning

Together, they form a strong defense for stable, secure shared hosting.


💬 Need Help Configuring Cgroups?

If you’d prefer expert setup and optimization for your hosting plans:

📨 Contact Servers9 Support — we’ll configure Cgroups, PHP resource limits, and firewall rules for maximum performance and security.