Server Resource Troubleshooting: CPU, memory and disk on a VPS

After this session you will be able to:

1. The basics in 5 minutes

Think of a VPS as a small restaurant kitchen

ResourceIn the kitchenWhen it runs out
CPUThe cooksOrders wait in line. The site gets slow or times out.
RAM (memory)The counter space where cooks workNo room to work. Things get pushed to the floor (swap, very slow), or the kitchen throws a dish away (the kernel kills a process).
DiskThe pantryNothing new can be stored: uploads fail, the database stops, logs can't be written.

Our role: the VPS is self-managed

First look, no commands needed: hPanel → VPS → Overview shows CPU, memory, disk and bandwidth graphs. They tell you what is full and since when. The commands below tell you why.

2. The toolbox: 8 commands

CommandShowsBad sign
uptimeLoad average (1, 5, 15 minutes)Load higher than the number of CPUs for a long time. A KVM 1 has 1 CPU, so a load of 3 means 3 jobs for every cook.
topLive list of processes. Press P to sort by CPU, M by memory, c to see the full command (apps often just show as python3, node, java or php-fpm).One process near 100% CPU, or using most of the RAM.
free -hMemoryThe available column near zero. (A small "free" number is normal: Linux uses spare RAM as cache.)
df -hDisk space per partitionUse% above 90%.
df -iInodes (how many files can exist)IUse% at 100% even with free space. Usually millions of tiny files (sessions, cache).
du -xh --max-depth=1 / | sort -hWhich folders are bigOne folder far bigger than expected.
journalctl -k | grep -iE "oom-kill|killed process"Processes killed for lack of memory, and which service they belonged toAny line at all.
vmstat 1 10CPU details every second: wa (waiting for disk) and st (steal)wa high for a long time; st above 10% consistently.

Also useful: systemctl status <PID> shows which service a process belongs to, and lsof +L1 lists deleted files that are still open. Nicer tools like htop, ncdu and iotop may not be installed; everything above works on a fresh VPS.

3. Golden rules

  1. Find the process first, then the reason. "CPU is high" is a symptom. "php-fpm is at 100% because of a stuck import" is a cause.
  2. Killing a process isn't a fix. If a service or cron job starts it, it comes back.
  3. Never delete what you don't understand. Ask the customer before removing backups, databases or anything in /var/lib.
  4. Unknown process name + high CPU = check for compromise. Crypto miners often hide behind random or system-looking names.

4. Real-world cases (with live labs)

Each case runs on the lab VPS srv2196542. The instructor starts it from the lab control page, you open the VPS Browser terminal in hPanel and diagnose it like a customer would. Section 7 explains how to run the lab.

Case 1: "My VPS is at 100% CPU and the site is very slow"

Lab scenario: cpu
"CPU is always at 100% in hPanel. I killed the process that was using it, but a few seconds later it's back."

What's going on: a worker program is stuck in a loop. It runs as a service that restarts it automatically, so killing it only works for a few seconds.

How to check:

  1. top, then press P: image-resizer at ~100%.
  2. Kill it: kill <PID>. Run top again: it's back with a new PID.
  3. Find who starts it: systemctl status <PID> → image-resizer.service.

Fix: systemctl stop image-resizer, then systemctl disable image-resizer so it doesn't start after a reboot. On a real server, the customer or developer then fixes the program itself. If it was started by cron, check crontab -l.

Real-world variants: a stuck WordPress cron or import, a bot flood on php-fpm, or a crypto miner after a hack. The last one is a security case: the customer must investigate and secure the VPS.

Case 2: "My RAM is almost full"

Lab scenario: memory
"hPanel shows memory at 80–90% all the time. Is my VPS too small?"

What's going on: one app is holding most of the memory.

How to check:

  1. free -h: look at available, not "free".
  2. top, then press M: a python3 process uses about 70% of the memory. Press c: the full command is /opt/lab/bin/report-builder.
  3. systemctl status <PID> → report-builder.service.

Fix: restart or stop the app (systemctl restart report-builder). On real servers the usual suspects are MySQL/MariaDB, too many PHP-FPM workers, Node.js apps and Java. Tuning them, or a bigger plan, is the long-term fix.

Not every "full" RAM is a problem. If free -h shows plenty available, Linux is just using spare memory as cache. That's healthy, and it's given back when an app needs it.

Case 3: "My database / app keeps stopping by itself"

Lab scenario: oom
"Every few minutes my app goes down and comes back. Nothing in the app's own log."

What's going on: a process keeps using more and more memory (a memory leak). When RAM runs out, the Linux kernel kills the biggest process to save the server: the OOM killer (out of memory). The service restarts it, and the cycle repeats.

How to check: journalctl -k | grep -iE "oom-kill|killed process". You'll see Out of memory: Killed process 1234 (python3), and on the oom-kill line, task_memcg=/system.slice/log-parser.service: that's the service. In top (M) you can watch its memory grow again after each restart.

Fix: stop the leaking service (systemctl disable --now log-parser) and have the developer fix the leak. Adding swap or upgrading only buys time.

On real servers the victim is often mysqld: it's usually the biggest process, so it gets killed even when another app caused the shortage.

Case 4: "Disk is full, uploads and the database are failing"

Lab scenario: disk
"My site shows database errors and I can't upload anything. hPanel says the disk is almost full, but my site is small."

What's going on: a debug log grew huge, and old backups were never removed.

How to check:

  1. df -h: / at ~97%.
  2. du -xh --max-depth=1 / | sort -h, then repeat inside the biggest folder (for example du -xh --max-depth=1 /var | sort -h).
  3. You find /var/log/shop-app/debug.log (very big) and /root/backups/ with four old backups.

Fix:

Other usual suspects: journalctl --disk-usage (system logs; clean with journalctl --vacuum-size=200M), Docker images and volumes (docker system df), and mail queues.

Case 5: "My disk usage doesn't add up"

Lab scenario: disk-hidden
"df says about 20 GB more are used than du can find. I deleted the big log file and the space didn't come back!"

What's going on: a file was deleted while a program still had it open. Linux keeps the space reserved until that program closes the file. du can't see it (no name anymore), but df still counts it.

How to check: compare df -h with du -xh --max-depth=1 / | sort -h: they don't match. Then lsof +L1 lists deleted files still held open: a python3 process holds /var/log/log-shipper/buffer.log (deleted) of about 20 GB. systemctl status <PID> shows it's log-shipper.service.

Fix: restart the program that holds it: systemctl restart log-shipper. In the lab, run systemctl disable --now log-shipper to end the scenario. Run df -h again: the space is back.

Case 6 (no lab): "My VPS is slow but my processes use little CPU"

"top shows my apps at low CPU, but everything is slow."

Look at the CPU line at the top of top (or the vmstat 1 10 columns):

CPU steal procedure:

5. What to ask the customer

We can't open the VPS, so ask for these as screenshots:

  1. What runs on it? A panel (CloudPanel, Plesk…), Docker, a game server, a single app?
  2. Since when, and what changed? An update, new plugin, import, traffic spike, new cron job.
  3. The hPanel graph for the resource (VPS → Overview).
  4. The matching commands:
Make it easy for them: customers not comfortable with commands can ask the AI Agent in the VPS Web Console ("why is my CPU at 100%?"). It runs these checks for them.
In our chat: send each command on its own line, without code blocks (```), since they break the chat.

Prevention tips to share

6. Practice: which case is it?

1. "I deleted a 15 GB log yesterday and df still shows the disk full."

Answer

Case 5. A program still holds the deleted file. lsof +L1, then restart that program.

2. "MySQL crashes at random times. The MySQL log just says it was restarted."

Answer

Case 3. Check journalctl -k | grep -iE "oom-kill|killed process" for the OOM killer, then find what's using the memory.

3. "free -h shows only 200 MB free, but available says 3.1 GB. Should I upgrade?"

Answer

Case 2's warning: no. Available is what matters; the rest is cache.

4. "There's a process called kdevtmpfsi using 400% CPU. I didn't install it."

Answer

Case 1, security variant: an unknown process at high CPU is a likely crypto miner. The customer must investigate and secure the VPS (the AI Agent can help).

5. "top shows my apps at 5% CPU, but the st value is 35% all day."

Answer

Case 6, CPU steal. Ask for screenshots of top and vmstat 1 10; above 10% consistently, investigate and consider a node transfer request.

7. Running the lab

  1. Instructor: open the lab control page (link shared by the instructor) and click start on one scenario. Or, in the VPS terminal: lab start cpu (names: cpu, memory, oom, disk, disk-hidden).
  2. Wait 1–2 minutes. The hPanel graphs may take a few minutes more to show it.
  3. Trainee: hPanel → VPS → srv2196542 → Browser terminal. Diagnose with the toolbox, then fix it like the case says.
  4. Reset: Stop all scenarios on the control page, or lab stop all.

Run one scenario at a time: the lab VPS is a KVM 1 (1 CPU, 4 GB RAM, 50 GB disk), the same size many customers have. All scenarios are harmless simulations and stop cleanly.


Built for Hostinger Customer Success. Commands are standard Linux tools; every lab scenario runs on a real Hostinger VPS.