Troubleshoot common performance issues
If your server is suddenly down or having performance issues and you’re not sure where to begin, this article outlines some first-aid troubleshooting steps for discovering the cause.
Check out this video for steps to troubleshoot some common server issues.
Check server disk usage
A full disk will cause many different issues that don’t appear related. Identifying a full disk is fairly straightforward, you can either:
-
Use the ServerPilot dashboard to identify your fullest disk, or
-
SSH to the server and run the following command:
Terminal window df -hThis command outputs the current disk usage of the server’s disks. Check the rows under the
Use%column for any disks at or near100%, particularly the drive with/in theMounted oncolumn.
If you find that the server’s disk is full, you’ll need to free up space by finding and removing unnecessary files on your server.
Alternatively, you can expand the size of your server’s disk. Check the documentation of your hosting provider to learn the necessary steps for your server.
Check server memory usage
Hosting large PHP apps or multiple websites on a single server can often result in high memory usage. If the server doesn’t have enough memory to fulfill these needs, then many different issues can occur.
To see if a server is running out of memory, connect to the server via SSH and run the following command:
grep "Out of memory" /var/log/syslogIf you get any output from this command, then your server is running out of memory and is being forced to kill processes. The output would look similar to this:
Jan 01 01:01:01 ServerName kernel: [72874642.714811] Out of memory: Kill process 29289 (php-fpm) score 1030 or sacrifice childHigh memory usage is usually caused by an increase in traffic to an app, slowness in an app’s code, or a combination of both. If the cause is high traffic, then increasing the server’s total memory should mitigate the issues.
If there are still issues after increasing the server’s memory, then you likely need to fix slowness in an app’s code. Read the section below titled “Check the PHP slow log” for help in identifying problem areas in the code.
Perform a server reboot
Once you’ve verified that the issues aren’t being caused by disk space or memory, performing a simple reboot can often resolve unexpected server issues. One drawback of performing a reboot is that it does cause downtime, so it must be planned accordingly.
To perform a reboot, SSH to the server and run the following command:
sudo rebootThis will trigger a graceful shutdown of the server which allows processes to stop safely, then the server will turn on and boot back up.
Check the PHP slow log
If a site is loading very slowly or not at all, then it’s possible there’s a slowness issue with the app’s code. This can cause memory issues at the server level and disrupt other apps. To identify these kinds of issues, you should check the PHP slow request log.
Check the MySQL slow query log
Sometimes performance issues on a server or website can be caused by SQL queries that take too long to execute. To identify queries that may be impacting your server’s performance, check the MySQL slow query log.