Performance and monitoring
Analyse slow PHP requests with X-Ray
PHP X-Ray lets you trace PHP requests to find the SQL queries, functions and external calls that take up time. Its purpose is to link a slow operation to the work the application does, not to apply an automatic fix.
Prepare a sample
Note a URL or operation you can reproduce, the time and whether it requires a login. First check whether the account is hitting its CPU or memory limits: that throttling can distort the times you observe.
A page served from a cache may not run PHP and, therefore, may not produce the trace you expect. Choose a representative operation and check which layer handles the request.
Start the analysis
- In cPanel, open X-Ray or X-Ray app and click Start tracing.
- Select the right domain.
- In the URL pattern or Specify mask, limit the scope to the problematic path following the field's help text. A pattern with an asterisk can widen the sample a lot.
- In Advanced settings, check the maximum number of requests and the duration. Start with few requests and a short interval; do not assume a fixed default value.
- Start with Run, reproduce the operation and stop the analysis when you have enough samples.
CloudLinux's user documentation describes the features available for each version. If the tool does not appear, ask whether it is available for your service.
Read the report
Sort the requests by duration and open a representative one. Check the total time, the URL, and the components, queries and external calls the report identifies.
Tell a single slow operation apart from a fast one repeated hundreds of times. A function appearing in the stack does not prove it is the cause: it may be waiting for another function or an external server.
Compare several samples. If the analysis flags resource limits, take them into account before blaming the code for the whole delay.
Turn the diagnosis into a test
Identify a specific hypothesis, for example a query without a suitable index, a slow external call or a plugin that repeats work. Test the change on a copy and compare the same operation under similar conditions.
Also check that everything still behaves correctly: reads, writes, forms and scheduled tasks. A faster time does not make up for wrong data or lost functionality.
Finish and share
Tracing adds work to the requests being analysed. Do not leave it running for long periods without need, and confirm that the task has finished.
If you export a report, check queries, URLs, parameters and personal data first. Share only the evidence needed with whoever has to solve the problem. X-Ray does not by itself measure all of the browser's rendering and JavaScript time; use the browser's tools for that part.
You may also find useful
- PageSpeed Insights: read the report and improve a website Interpret PageSpeed Insights metrics and make gradual improvements in WordPress with LiteSpeed Cache...
- Interpret WordPress Site Health warnings Interpret WordPress Site Health warnings about themes, PHP, modules, updates, HTTPS, the REST API an...
- Proactive+: monitoring and technical review of incidents Enable Proactive+ per domain, save notes and restore permissions, and use maintenance mode to pause...
- Setting up website monitoring Create availability, content and SSL monitors, set up email alerts and check response times, inciden...
Something wrong or out of date? Tell us and we will review it.