Troubleshooting VPS Performance

Published on

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

VPS hosting

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

The Diagnostic Flow

SymptomFirst CheckTool
Everything slowCPU and memoryhtop
Website slowDisk I/Oiotop
Connection dropsNetworkss, nethogs
Out of memoryMemory usagefree -h
Disk fullDisk spacedf -h

htop: Your Primary Tool

sudo apt install htop
htop

Reading htop

SectionWhat to Look For
CPU barsAll cores near 100% = CPU bottleneck
Memory barOver 90% = memory pressure
Swap barAny usage = memory shortage
Load averageAbove CPU count = overloaded
Process listWhich process uses the most CPU/RAM

Load Average Guide

Load Average vs CPU CoresStatus
Load < coresHealthy
Load = coresFully used
Load > coresOverloaded
Load > 2x coresSeverely 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

ProcessCauseSolution
mysql/mariadbUnoptimized queriesAdd indexes, optimize queries
php-fpmHeavy PHP processingEnable OPcache, add caching
nodeUnoptimized code or memory leakProfile and fix code
apache2Too many concurrent connectionsTune MaxClients
pythonData processing taskOptimize or schedule off-peak

Memory Troubleshooting

# Memory overview
free -h

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

When Memory is Low

ActionImpact
Restart PHP-FPMClears memory leaks
Reduce MySQL buffer poolFrees memory
Kill unused processesImmediate relief
Add swapTemporary fix
Upgrade VPSPermanent 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

CulpritLocationSolution
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

SignCurrent Plan Issue
Consistent load > coresNeed more CPU
OOM kills in logsNeed more RAM
Disk constantly > 80%Need more storage
Bandwidth limits hitNeed 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.

Ready to deploy?

KVM VPS from EUR 5.50/mo with full root access, NVMe storage, and DDoS protection included.