If your website is slow, there are a few things that can be checked in a simple way.
The possible causes are:
- Site uses not optimal PHP version
- Server-side problems: web or MySQL service workload/bad optimisation.
- Network problems: connection is not stable or bandwidth is not sufficient.
- Website code problems: content size and website code optimization.
- Slow DNS servers are used.
And we will check how to troubleshoot each one.
Site uses not optimal PHP version
For the PHP version, sometimes your website needs a specific version to run a few applications, however many times using a deprecated version can slow down the website and avoid plugins upgrades if you are using WordPress.
Switch PHP to highest possible version in Domains > example.com > Hosting Settings
Server-side problems: web or MySQL service workload/bad optimisation
Although there are a few ways to check if it is a server issue, we are always checking on our side and making sure everything is running smoothly from here.
On your side, it is possible to check your database. A slow query log can be used to find queries that take a long time to execute and are therefore candidates for optimization.
You can also check and repair from Plesk panel following the screenshot:
If you want to go beyond, via terminal it is possible to run a slow query log to fix the most slow ones, but it will require the help of a developer.
If from the other location/network it opens fine, but from browser or other location it doesn't, you need to test your network connection bandwidth and stability. If small, the next step might help you to compress the website.
When most of the bandwidth is taken by DNS, test the website with another DNS servers, for example use 18.104.22.168 Google DNS to check if the issue persists.
Improving Website Code
- If the website is "heavy", optimize its size by compressing images, for example.
- Use Fiddler or webpagetest.org to find out which HTTP requests take the most time to execute: it can be slow authentication requests, .aspx pages compiled slowly due to antivirus or not optimized script.
- If the website is written in PHP and served by PHP-FPM, slowlog can be enabled. It allows logging scripts (not just their names, but their PHP backtraces too, using ptrace and similar things to read remote process' execute_data) that are executed unusually slow.
To enable it go to Plesk > Domains > example.com > PHP Settings > Additional directives > Additional configuration directives
slowlog = /var/www/vhosts/example.com/slow.log
request_slowlog_timeout = 5s
You can replace 5s with any other value. This will help find scripts which execute slowly. Image resizing function, network I/O related functions are some examples which will frequently show-up in PHP slowlog.