A slow website is frustrating. You click a link, and it just spins. That’s not fun for anyone—not for you, not for your visitors, and not even for your server (it’s probably sweating).
When your website is hosted on a Linux VPS (Virtual Private Server), you’re in charge of keeping things fast and healthy. That means figuring out why it’s slow and fixing it. In this article, I’ll show you how I troubleshoot slow websites using simple tools and methods.
I’m not a super genius, and you don’t need to be either. If you know how to use the terminal and read basic error messages, you can do this.
Let’s dive in before your site takes another nap.
What Is a VPS?
A VPS is a virtual private server. It’s like renting a small apartment on a big server. You have your own space, but you still share the building (the hardware) with others.
Compared to shared hosting, a VPS gives you more control. But with great power comes great… weird problems.
When something goes wrong, you are the tech support. But don’t worry—I’ll help you figure out what’s slowing down your site.
How Do I Know My Website Is Slow?
Sometimes, people email me saying, “Your site isn’t loading.” Other times, I feel it myself when a page takes 10 seconds to appear. That’s when I know it’s time to check.
You can also use tools like:
These tools tell you how long your site takes to respond and what might be wrong.
But that’s just the surface. The real detective work happens inside your Linux VPS.
Step 1: Check Your VPS Load
This is the first thing I do.
Open your terminal and type:
top
Or, even better:
htop
If you don’t have htop
, install it:
sudo apt install htop
This shows you what’s using your CPU and memory. If you see something like php-fpm
or mysql
at 100%, that’s a clue.
You can also run:
uptime
This shows your server’s load average. If those numbers are much higher than the number of CPU cores you have, something is hogging resources.
Fun fact: If your server is too “loaded,” it might need a snack—like a memory upgrade.
Step 2: Check Available Disk Space
A full disk can make your website crawl like a snail on vacation.
Run:
df -h
This shows how much space is left on each partition. If your /
or /var
partition is 100%, you’ve got a problem.
I once had a slow website because logs were piling up in /var/log
. Deleting old log files gave my server room to breathe again.
You can find large files using:
du -sh /*
Or check for big logs:
sudo du -sh /var/log/*
Step 3: Check Running Processes
Sometimes your server is busy doing something useless—like a stuck backup script or a runaway cron job.
Use:
ps aux --sort=-%cpu | head
This shows which processes are eating your CPU.
Kill a bad process (gently) with:
sudo kill -9 PID
Replace PID
with the process ID from the list. But be careful not to kill something important like nginx
or mysqld
.
Step 4: Check Web Server Logs
Your web server might be trying to tell you something. Logs are where it leaves notes.
If you use Nginx, check:
sudo tail -n 100 /var/log/nginx/error.log
If you use Apache, check:
sudo tail -n 100 /var/log/apache2/error.log
Look for messages like “timeout,” “bad gateway,” or “can’t connect to database.”
If your logs are full of errors, fixing those can make your site run much faster. Logs are like your server’s diary—sometimes it just needs someone to read it.
Step 5: Check Database Health
If your site uses a database (like WordPress does), that could be the problem.
Log in to MySQL or MariaDB:
sudo mysql -u root -p
Check running queries:
SHOW PROCESSLIST;
If you see many slow queries or “locked” tables, that’s a red flag.
You can also check:
mysqladmin -u root -p processlist
Make sure your database has enough memory to work with. A well-fed database is a happy database.
Step 6: Check for Bots and Bad Traffic
Sometimes bots or attackers hit your site with lots of requests. That can slow things down or even crash the server.
To see current traffic, run:
sudo netstat -tn 2>/dev/null | grep ':80' | wc -l
Or use:
sudo tail -f /var/log/nginx/access.log
Look for repeated requests from the same IP. You can block them using a firewall like ufw
:
sudo ufw deny from 192.168.1.100
You can also use tools like fail2ban to block bad visitors automatically.
Step 7: Check PHP and Caching
If your website uses PHP (like WordPress), slow PHP scripts can drag things down.
Make sure PHP-FPM is running smoothly:
sudo systemctl status php7.4-fpm
Or whatever version you use.
Try restarting it:
sudo systemctl restart php7.4-fpm
Use a caching plugin or server cache like Redis, Memcached, or even plain old HTML caching.
A website with caching is like a student using notes instead of reading the whole book every time.
Step 8: Run a Simple Speed Test from Your Server
Run this to test how fast your site loads from the server itself:
curl -o /dev/null -s -w "%{time_total}\n" http://localhost
If it takes more than 1–2 seconds, something inside the server is slow.
Try turning off plugins, themes, or scripts to see what’s causing the problem. Sometimes, one line of code can slow everything down—like a bad apple in a fruit basket.
Handy Tools to Keep Around
Here are a few command-line tools I use all the time:
htop
– check CPU and RAM usageiftop
– see which IPs use your networkiotop
– monitor disk usage
Install them with:
sudo apt install htop iftop iotop
They help me figure out if the slowdown is caused by CPU, memory, disk, or network.
Signs Your VPS Is Too Small
Sometimes, it’s not your code—it’s just that your VPS needs more muscle.
Here are signs your VPS may be underpowered:
- Load average is always high, even with few visitors
- RAM is always full and swap is constantly used
- Website works fine at midnight but dies during the day
Upgrading your VPS is like going from a bicycle to a scooter—more speed, less sweat.
Troubleshooting Checklist
Here’s a short list you can go through when your site is slow:
- Check CPU and memory with
htop
- Check disk space with
df -h
- Read web server logs
- Review database status
- Check PHP and caching setup
- Look for bad bots and high traffic
- Run a speed test with
curl
Final Thoughts
Troubleshooting a slow website might feel like chasing ghosts. But with the right steps, you can find what’s wrong and fix it.
I’ve made plenty of mistakes—like restarting the wrong service or deleting the wrong file. But each time I learned something. And over time, fixing slow websites got easier.
Remember, every VPS has its limits. But a well-tuned server can serve pages faster than you can say “loading…”
If your site still feels slow after all this, maybe it’s time to audit your code, plugins, or even consider a different setup. Just don’t forget to keep backups. Always.