The short answer
Measure time to first byte with curl. A high value means the server or the application is slow. A low value with a slow page means the page itself is heavy.
Measure from outside
curl -o /dev/null -s -w "dns %{time_namelookup}s connect %{time_connect}s tls %{time_appconnect}s first byte %{time_starttransfer}s total %{time_total}s\n" https://example.com/A high first byte time means the server is slow to answer: look at PHP, the database and the load. A low first byte time with a slow page means a heavy page (images, scripts) and you should use a front-end test such as Lighthouse.
Check the server at the same moment
uptime
free -h
iostat -x 2 3
ss -sHigh load, no free memory, high disk wait (%util and await) or thousands of connections each point to a different cause.
PHP workers
If all PHP-FPM workers are busy, new visitors wait. Look in the PHP-FPM log for "server reached pm.max_children". More workers use more memory, so first find out why requests are slow. A slow plugin that holds workers for seconds is the usual reason.
Database
Look at the process list and the slow query log. See MySQL slow? Find heavy queries.
Caching
- A page cache serves repeat visitors without running PHP.
- An object cache such as Redis takes load off the database.
- Browser caching and compression reduce repeat downloads.
Disk and network
- Slow disks make everything slow. Check
iostatand the free space. - A server far from your visitors adds delay. Test from where your visitors are.
Change one thing at a time
Make one change, measure again and write down the result. Otherwise you never know what helped.
Questions people ask
Will a bigger server fix it?
Only if the server is the limit. A slow query or plugin stays slow on any size.
What is a good time to first byte?
Under about 0.5 seconds is usually fine for a cached page. Dynamic pages take longer.
Can you tune it for me?
Yes. Start with a free check and we will tell you what we see.