How to Diagnose a Slow Site and 504 Timeouts in xCloud
Updated December 4, 2026 · 10 min read
A slow site or a 504 Gateway Timeout almost always means PHP on your server could not finish a page in time. Either all of the site’s PHP workers are busy, one page is slow because of a database query or an outside service, or the server itself is short of CPU or memory. Check in this order: server load, PHP workers, slow pages, database queries, then logs. Each check below tells you where the result leads, so you fix the real cause instead of raising limits.
Written by the xCloud Docs Team · Updated December 4, 2026
From our support desk: A nonprofit’s site went down for a few minutes, came back, and then took about three minutes to open its volunteer page. There was no error, and the server itself was healthy. The access log showed AI crawlers and a scraper requesting event calendar links with query strings, around half a million requests in one day. The page cache can’t serve those links, so every PHP worker stayed busy and real visitors waited in line. Blocking the crawlers on those calendar URLs at Cloudflare brought the page back to normal speed.
What each result means
| What you find | Likely cause | What we recommend |
|---|---|---|
| CPU near 100% across several refreshes | Too many requests, often bots | Find the busy site and block the traffic |
| CPU low, all PHP workers busy | Slow requests hold every worker | Find the slow page (Step 3) before you add workers |
| One page slow, the rest fine | A slow query, plugin or outside API call | Slow Pages and the debug log (Steps 3 and 5) |
| Queries “Waiting for table metadata lock” | A database lock | Find what holds the lock (Step 4) |
| Cloudflare 524, server fast when tested directly | A long request behind the CDN | Fix the slow request; don’t raise the timeout |
Step 1: Check the server’s load
Open the server and go to Monitoring → Monitoring. In Server Health, read the CPU Usage and RAM cards. Click Refresh a few times, because CPU readings change fast.

- CPU stays near 100%: the server is overloaded. Follow Server at 100% CPU to find the busy site and the traffic behind it.
- RAM is almost full: PHP or MySQL may be swapping or restarting. See Database keeps stopping.
- CPU and RAM look normal, but the site is slow: the site is waiting, not working. Go on to Step 2. In our test, this screen showed 1% CPU while the site’s homepage didn’t load for 30 seconds.
Server monitoring and Site Insights are part of paid plans. On the free plan, use the SSH commands below.
Step 2: Check whether PHP workers are full
Each site has a fixed number of PHP workers, set by Max PHP Workers in the site’s PHP settings. When every worker is busy, new visitors wait in a queue until one is free. If they wait longer than the server’s time limit, they get a 504.
Open the site and go to Site Insights → PHP. Open Running Processes and click Refresh. Read the workers active count next to Running PHP Processes.

- Workers active equals Max PHP Workers, and the Elapsed times keep growing: PHP is full. Go to Step 3 to find which requests hold the workers.
- Workers are full and CPU % is high on each: the code is doing heavy work, often for bots. Check the traffic in Site Insights → Traffic.
- Workers are free: PHP is not the bottleneck. Go to Step 4.
Adding workers only helps when the server has spare CPU and RAM. If the workers are stuck on slow requests, more workers just means more stuck requests. Use Auto-tune in the site’s Manage FPM Configurations window to set a safe number for your server’s memory; see How to configure PHP settings.
Step 3: Find the slow pages
Open Site Insights → PHP → Slow Pages. Set Slow Log to On - Enabled, choose a Slowlog Timeout in seconds (5 is a good start), and click Save & Reload PHP-FPM. Saving reloads PHP for every site on the server that uses the same PHP version, so do it at a quiet time. Wait until the site is slow again, then click Fetch Log.
Each entry in Slow Log Entries shows the Script and a Stack Trace. Read the stack trace from the top: the first lines name the function that was running when PHP took too long.
curl_exec,file_get_contentsorwp_remote_get: the page waits for an outside service, such as a licence check, an API or a feed. Fix or disable that plugin feature.mysqli_queryorwpdb->query: the page waits for the database. Go to Step 4.- The same plugin folder in most traces: that plugin is the slow part. Test with it disabled on a staging site.
On OpenLiteSpeed servers the same tab shows Response Time Logging and Slow Page Threshold. Save with Save & Restart OLS. Slow URLs appear under Slow Response Entries with their response time, without stack traces. On OpenLiteSpeed, saving restarts the web server for every site on the server; do it at a quiet time.
Turn the slow log off again when you’re done.
Step 4: Check the database for slow or locked queries
Go to Site Insights → MySQL. Open Running Queries and click Refresh while the site is slow.

- A query with a long time and the state “Waiting for table metadata lock” or “Locked”: another query or a backup holds the table. Find the long-running query above it in the list; that’s the one to fix or stop.
- The same heavy query repeated many times: check All Queries for its count and Avg Time (s). A plugin search, a WooCommerce report or a missing index is the usual cause.
- No queries running: the database is not what holds the page up. Go to Step 5.
To keep a record, turn on the Slow Query Log in the same page and set Long Query Time (in seconds). MySQL is shared by every site on the server, so Every site on this server shows whether another site’s queries are slowing yours. The Site Insights guide explains every tab.
Step 5: Read the logs
Open the site and go to Site Monitoring → Logs (Monitoring → Logs on non-WordPress sites).
- Nginx Error Log: “upstream timed out” lines mean Nginx gave up waiting for PHP (the 504). “Connection reset by peer” or “Connection refused” lines mean PHP stopped or restarted mid-request (a 502).
- WordPress Debug Log: PHP fatal errors and plugin warnings. Turn debugging on first with the WP Debug tool, and turn it off when you’re done.
Note the time of the first error, then compare it with plugin updates, cron jobs or backups that ran at that time. See View logs and events for every log type.
Step 6: Rule out the CDN
If the site sits behind Cloudflare, look at the error page. A Cloudflare 524 means Cloudflare waited about 100 seconds for your server and gave up (Cloudflare’s 5xx error reference). Your server is still slow, so the steps above apply. A plain Nginx 504 page comes straight from your server.
If the same page is fast when you load it with the CDN bypassed but slow through it, check the CDN’s cache and security settings instead. See Troubleshooting Cloudflare issues for WordPress.
About the time limit behind a 504
On Nginx servers, xCloud sets how long Nginx waits for PHP from the Max Execution Time and Max Input Time values in your PHP settings. Nginx waits as long as the largest Max Execution Time or Max Input Time of any site on the server, or 300 seconds when none is set to a positive value. PHP stops a request at that same limit, unless any site has Max Execution Time set to unlimited; then PHP does not stop requests at all. We recommend keeping Max Execution Time near the suggested 60 seconds and raising it only on a site that needs long admin tasks, such as big imports. A higher limit doesn’t make a slow page faster; it only lets it hold a PHP worker for longer.
Using SSH or the web terminal
These commands give the same answers from the command line, and they work on any plan. Connect over SSH or open the web terminal and run them as root or with sudo. We ran each command on a test server while we made one site slow on purpose; the site user site_user and the domain example.com are placeholders.
Is the CPU busy or idle?
uptime
top -bn1 -o %CPU | head -12
Bad result: a load average above the number of cores (nproc prints it) and id (idle) near 0: the server is overloaded, so go to Server at 100% CPU. Our slow test site showed load average: 0.00 while its homepage hung, which pointed at waiting PHP workers.
Are the site’s PHP workers full?
Each site runs PHP as its own site user. Count its workers and see how long each has been running:
ps -u site_user -o pid,pcpu,pmem,etime,stat,comm
PID %CPU %MEM ELAPSED STAT COMMAND
2360 0.1 3.3 05:06 S php-fpm8.3
2361 0.0 3.0 05:06 S php-fpm8.3
2913 0.0 1.1 00:34 S php-fpm8.3
2914 0.0 1.1 00:33 S php-fpm8.3
Then check whether PHP has hit the site’s limit (use your PHP version in the file name):
grep "max_children" /var/log/php8.3-fpm.log | tail -5
[04-Dec-2026 12:38:02] WARNING: [pool site_user] server reached pm.max_children setting (4), consider raising it
Bad result: this warning, with low CPU on every worker. All 4 workers were waiting on slow requests, and new visitors queued behind them. On OpenLiteSpeed servers the processes are called lsphp and this log doesn’t apply; use Running Processes in Site Insights instead.
Which database queries are running or locked?
mysql -u root -p -e "SELECT ID, USER, DB, TIME, STATE, LEFT(INFO,50) AS QUERY FROM information_schema.PROCESSLIST WHERE COMMAND <> 'Sleep' ORDER BY TIME DESC;"
Enter the database root password when asked; Find the MySQL root password shows where it is.
ID USER DB TIME STATE QUERY
68 root wp_db 8 User sleep SELECT SLEEP(40)
69 site_user wp_db 6 Waiting for table metadata lock SELECT option_name, option_value FROM wp_options W
Bad result: “Waiting for table metadata lock”. In our test, one session held a lock on wp_options, and the homepage took 38 seconds to load until the lock was released. The query with the longest TIME above the waiting ones is usually the one holding the lock.
What does Nginx say?
tail -20 /var/log/nginx/example.com-error.log
upstream timed out (110: Connection timed out) while reading response header from upstream: Nginx waited for PHP until the time limit and returned a 504.recv() failed (104: Connection reset by peer) while reading response header from upstream: PHP stopped the request or restarted, and the visitor got a 502. We saw this on our test server when PHP restarted while long requests were running.
On OpenLiteSpeed servers the site logs are in /var/log/lsws/.
Check that it worked
After your fix, load the slow page a few times. In Site Insights → PHP → Running Processes, click Refresh: workers should finish and free up within seconds. Slow Log Entries should stop growing, and the Nginx error log should show no new “upstream timed out” lines. If the site is still slow under real traffic after the slow requests are fixed, the server may need more CPU or RAM; see how to upgrade your server.
Frequently asked questions
What is the difference between a 502 and a 504 error on xCloud?
A 504 means Nginx waited for PHP and gave up because the page took longer than the server’s time limit. A 502 means PHP closed the connection or wasn’t there to answer, for example because PHP restarted or a PHP process was stopped. Both send you to the same place: the PHP workers and the slow pages of that site. On OpenLiteSpeed servers the web server is OpenLiteSpeed, not Nginx, but the cause is the same: PHP took too long or stopped.
Should I just raise Max Execution Time to fix a 504?
Only for a known long task, such as a large import in wp-admin. For normal pages, a higher limit lets slow requests hold PHP workers even longer, so more visitors wait. Find the slow page or query first and fix that.
My server CPU is low, so why is my site slow?
Low CPU with a slow site usually means PHP is waiting, not working: all PHP workers are busy with slow requests, a database table is locked, or a plugin waits for an outside API. Check Running Processes and Running Queries in Site Insights.
How do I know if Cloudflare or my server is slow?
Look at the error page. A Cloudflare-branded 524 means Cloudflare waited for your server and gave up, so the server is slow. A plain Nginx 504 page comes from your server itself. If the site is fast when you bypass the CDN but slow through it, the problem is in the CDN settings.
Next step
To watch live which processes use CPU and memory while you test a fix, follow How to monitor system processes using htop.
Still stuck? Contact our support team for any of your queries.