Why is Your Server Lagging? Finding the "Bottleneck"
Greetings, friends!
Today, I want to talk about a situation that often happens to many people and companies: you’ve rented a great server, set up a proxy, or launched a website, but at some point, everything just starts to... well, lag. Pages take forever to load, the console hangs, and commands execute with a noticeable delay.
For many, the first instinct is to blame the hosting provider. However, more often than not, the cause lies within the system itself, and your provider can’t really influence that. You could upgrade to a more powerful server, but even that doesn't always help. In this article, we will figure out how to find the "bottleneck" and understand which resource your server is lacking—because sometimes you just need a few more gigabytes of RAM, while others might actually need a new CPU.
What is a "Bottleneck"?
The simplest explanation that everyone can understand is this: imagine a five-lane highway that suddenly narrows down to just one. No matter how fast the cars are, they will all get stuck in a traffic jam. On a server, these "lanes" are the four main resources: Processor (CPU), Random Access Memory (RAM), Disk (Disk I/O), and Network.
To give you a better understanding, let's check each of them.
Processor (CPU): When the "Brains" Overheat
If your processor is loaded at 100%, the server simply doesn't have time to process the queue of requests, which significantly slows down the server's operation.
How to check: Connect via our favorite BitVise SSH and enter the command:
htop(If you don't have it, install it with:sudo apt install htop). This command is for Ubuntu.What to look for:
At the top, you will see scales for each core's load. If they are all red, the processor is overloaded.
Look at the PRI (priority) and CPU% columns in the process list. This is how you find the specific program that is "devouring" resources.
There are also various monitoring programs you can use, such as Zabbix, SmokePing, etc. If the CPU is at 100%, you need to offload it by disabling some applications or upgrade to a plan (or install a new CPU if it’s a private server) with a more powerful processor.
Random Access Memory (RAM): Nowhere to Write
When memory runs out, Linux starts using Swap (a paging file on the disk). Since even the fastest NVMe disk is many times slower than RAM, the server begins to lag mercilessly.
How to check:
free -mWhat to look for:
The available column. If there is less than 100-200 MB left, you have a problem.
If the value in the swap -> used column is constantly growing, it means the server is catastrophically short on RAM.
In this case, you can either stop unnecessary services or increase the amount of RAM. By increasing the volume, you protect yourself, but if you don't figure out the root cause, you might encounter this problem again later.
Recently, we had a case where a client contacted us saying they were out of memory and asking for a higher-tier package. Our tech department helped identify an issue with their plugins; the client simply got rid of the unnecessary plugins and didn't have to switch to a more expensive plan.
Disk Activity (Disk I/O): The Writing Queue
Sometimes the CPU and RAM are free, but the server still hangs. Most likely, the disk cannot keep up with reading or writing data (for example, a database is making too many requests).
How to check:
iotop(must be run viasudo).What to look for:
The DISK READ and DISK WRITE columns.
Pay special attention to the IO> parameter. If it is higher than 10-20%, your disk has become that very bottleneck. On MivoCloud servers with NVMe disks, this happens rarely, but it’s worth checking during high DB loads.
Generally, a server doesn't hang because of the disk very often, but it can happen. If you are using an HDD, the chance of a hang is many times higher than on a server with an NVMe drive, as NVMe is significantly faster than HDD.
Network: The Narrow Channel
If you have deployed a proxy server or streaming service, the problem may be in the channel's bandwidth or high latency.
How to check:
nloadoriftop.What to look for:
Compare the current load with your tariff limit. If you have a 1 Gbps port and the load is hitting 900 Mbps, it’s time to expand the channel.
Logs: The Invisible Space Killer
Sometimes a server slows down simply because the disk has run out of space due to bloated logs. The system cannot create a temporary file and falls into a "stupor."
How to check:
df -hIf you see 100% on the main partition (
/), immediately clean the logs in/var/log. You can also set up automatic log cleaning once a month to avoid this situation.
FAQ: Briefly About the Essentials
What slows down a server most often? Usually, it’s a lack of RAM or poorly configured scripts that load the CPU.
Will a reboot help? It will help temporarily clear the memory, but it won't solve the "bottleneck" problem. You need to find the cause and eliminate it.
Why are there still lags on Ryzen? Even the most powerful processor won't save you if you have a slow script running in a single thread or if the network is congested.
Conclusion
Finding a Bottleneck is detective work. The main thing is not to guess, but to use monitoring tools. Now that you know the basic commands, you can understand in 2 minutes whether it’s worth switching to a more powerful plan or if you just need to optimize your code.
Author - Anatolie Cohaniuc

