High CPU / load / disk full
## High CPU usage, load or full disk
Performance problems in a VPS container usually fall into one of three categories: **CPU bottlenecks**, **memory exhaustion** or **disk space exhaustion**. This guide shows how to identify and mitigate each issue.
### 1. Diagnosing CPU bottlenecks
- **Check the load average** – Run `uptime` or `top` and look at the three load averages. Values higher than the number of CPU cores indicate that processes are queued and waiting for CPU time.
- **Identify CPU‑hungry processes** – Use `top`, `htop` or `ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head` to see which processes are consuming the most CPU time. Applications like poorly configured web servers, loops in scripts or runaway cron jobs are common culprits.
- **Take corrective action** – Once identified, you can:
- Restart or reconfigure the offending service (e.g., limiting worker processes in Apache/Nginx or tuning PHP‑FPM settings).
- Kill runaway processes (`sudo kill -9 <PID>`) if they are not essential.
- Optimise your code or database queries to reduce CPU usage.
- If high CPU usage is sustained and legitimate, upgrade to a larger plan with more vCPUs.
### 2. Diagnosing memory issues
- **Check free memory** – Run `free -m` to view total, used and free memory. If swap usage is high and free memory is low, the system may be thrashing.
- **Find memory hogs** – Use `top` or `ps -eo pid,comm,%mem --sort=-%mem | head` to locate processes consuming excessive RAM.
- **Actions to take**:
- Restart services to clear leaked memory or free caches.
- Adjust application settings to limit memory usage (e.g., reducing PHP `memory_limit` or database buffer sizes).
- Add swap space to provide breathing room (temporary fix) or upgrade to a plan with more RAM for sustained needs.
### 3. Diagnosing disk usage
- **Check disk space** – Run `df -h` to see filesystem usage and `du -sh /var/*` to identify large directories. If `/`, `/var` or `/home` is 100 % full, the system may become unresponsive.
- **Clean up**:
- Remove old logs in `/var/log` and rotate large log files.
- Delete unused package caches (`sudo apt clean` or `sudo dnf clean all`).
- Clear temporary files in `/tmp` and `/var/tmp`.
- For web servers, delete old backups or unneeded uploads.
- Trim journal logs (`sudo journalctl --vacuum-time=3d`) to retain only recent messages.
### 4. Preventive practices
- **Monitor regularly** – Install monitoring tools (e.g., `htop`, `glances` or `Netdata`) to track CPU, RAM, disk and network usage over time.
- **Optimise applications** – Configure web and database servers for your workload: enable caching, set appropriate worker limits and query caches.
- **Use alerts** – Set up alerts to notify you when CPU load, memory usage or disk space exceed thresholds. Many control panels (including IllusionCloud’s) offer resource graphs and alerts.
- **Scale up when needed** – If your workload outgrows the allocated resources, consider upgrading to a larger LXC plan or moving to a KVM VPS or dedicated server.
### Summary
High CPU load, memory exhaustion and full disks are common causes of poor performance. By using standard Linux tools (`top`, `free`, `df`, `du`) and log files, you can quickly identify the bottleneck. Optimising services, cleaning up unneeded files and upgrading resources when necessary will keep your container healthy and responsive.