Troubleshooting VPS Performance: A Practical Guide with top, htop, and More

Published on

How to diagnose and fix VPS performance issues. Covers CPU, memory, disk, and network troubleshooting with practical command-line tools and solutions.

Written by Space-Node Team – Infrastructure Team – 15+ years combined experience in game server hosting, VPS infrastructure, and 24/7 streaming solutions. Read author bio →

Your VPS feels slow. Here's how to find out why and fix it.

The Diagnostic Flow

| Symptom | First Check | Tool | |---------|------------|------| | Everything slow | CPU and memory | htop | | Website slow | Disk I/O | iotop | | Connection drops | Network | ss, nethogs | | Out of memory | Memory usage | free -h | | Disk full | Disk space | df -h |

htop: Your Primary Tool

sudo apt install htop
htop

Reading htop

| Section | What to Look For | |---------|-----------------| | CPU bars | All cores near 100% = CPU bottleneck | | Memory bar | Over 90% = memory pressure | | Swap bar | Any usage = memory shortage | | Load average | Above CPU count = overloaded | | Process list | Which process uses the most CPU/RAM |

Load Average Guide

| Load Average vs CPU Cores | Status | |--------------------------|--------| | Load < cores | Healthy | | Load = cores | Fully utilized | | Load > cores | Overloaded | | Load > 2x cores | Severely overloaded |

Example: 2-core VPS with load 1.5 is busy but healthy. Load 4.0 is overloaded.

CPU Troubleshooting

Finding the Culprit

# Top CPU processes
ps aux --sort=-%cpu | head -10

Common CPU Hogs

| Process | Cause | Solution | |---------|-------|----------| | mysql/mariadb | Unoptimized queries | Add indexes, optimize queries | | php-fpm | Heavy PHP processing | Enable OPcache, add caching | | node | Unoptimized code or memory leak | Profile and fix code | | apache2 | Too many concurrent connections | Tune MaxClients | | python | Data processing task | Optimize or schedule off-peak |

Memory Troubleshooting

# Memory overview
free -h

# Per-process memory
ps aux --sort=-%mem | head -10

When Memory is Low

| Action | Impact | |--------|--------| | Restart PHP-FPM | Clears memory leaks | | Reduce MySQL buffer pool | Frees memory | | Kill unused processes | Immediate relief | | Add swap | Temporary fix | | Upgrade VPS | Permanent fix |

MySQL Memory Optimization

MySQL often uses the most memory:

# /etc/mysql/mariadb.conf.d/50-server.cnf
innodb_buffer_pool_size = 256M   # Reduce if too high
key_buffer_size = 32M
max_connections = 50              # Reduce from default 151

Disk I/O Troubleshooting

# Install iotop
sudo apt install iotop
sudo iotop

Disk Space

# Filesystem usage
df -h

# Find large directories
du -sh /var/* | sort -rh | head -10

# Find large files
find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null

Common Disk Space Fixes

| Culprit | Location | Solution | |---------|----------|----------| | Log files | /var/log/ | Configure logrotate, clean old logs | | Old backups | /var/backups/ | Delete old backups | | Package cache | /var/cache/apt/ | sudo apt clean | | Old kernels | /boot/ | sudo apt autoremove |

Network Troubleshooting

# Active connections
ss -tuln

# Bandwidth per process
sudo apt install nethogs
sudo nethogs

# Network statistics
sudo apt install vnstat
vnstat

Quick Diagnostic Script

#!/bin/bash
echo "=== System Overview ==="
uptime
echo ""
echo "=== Memory ==="
free -h
echo ""
echo "=== Disk ==="
df -h /
echo ""
echo "=== Top CPU Processes ==="
ps aux --sort=-%cpu | head -5
echo ""
echo "=== Top Memory Processes ==="
ps aux --sort=-%mem | head -5
echo ""
echo "=== Network Connections ==="
ss -tuln | grep LISTEN

Save as diagnose.sh and run when something feels off.

When to Upgrade

| Sign | Current Plan Issue | |------|-------------------| | Consistent load > cores | Need more CPU | | OOM kills in logs | Need more RAM | | Disk constantly > 80% | Need more storage | | Bandwidth limits hit | Need more bandwidth |

Space-Node's VPS plans scale from small to large. Start with what you need and upgrade when monitoring tells you it's time, not before.

Space-Node Team

About the Author

Space-Node Team – Infrastructure Team – Experts in game server hosting, VPS infrastructure, and 24/7 streaming solutions with 15+ years combined experience.

Since 2023
500+ servers hosted
4.8/5 avg rating

Our team specializes in Minecraft, FiveM, Rust, and 24/7 streaming infrastructure, operating enterprise-grade AMD Ryzen 9 hardware in Netherlands datacenters. We maintain GDPR compliance and ISO 27001-aligned security standards.

View Space-Node's full team bio and credentials →

Launch Your VPS Today

Get started with professional VPS hosting powered by enterprise hardware. Instant deployment and 24/7 support included.

Troubleshooting VPS Performance: A Practical Guide with top, htop, and More