RunCloud provides a Slow Script Monitoring functionality that allows you to track which scripts are taking a long time to execute.

You can use this information to identify performance bottlenecks in your web application, helping you to optimize and improve overall site speed and efficiency.

But before we get started, you should note that Slow Script Monitoring is not supported on OpenLiteSpeed servers or Laravel Octane web applications. If you are not using this tech stack, then you can follow the steps below for enabling Slow Script Monitoring on your server:

  1. Log in to your RunCloud dashboard and navigate to your web app dashboard.

    On this screen, find and click on the “Monitoring” option in the sidebar menu.

    Next, click on the “Slow Script” tab to check if the monitoring has been already enabled.
  1. If the monitoring is not enabled, then you can click on the “Configuration” button and flip the toggle switch for “Slow Script Monitoring” and turn it on.

    Note: if you wish to disable slow script monitoring for any reason, then simply toggle the switch for “Slow Script Monitoring” to the off position, then click the “Save Configuration” button.
  2. In the same configuration section, look for the “Slow Script Threshold” field and enter a time value in seconds (e.g., 2 seconds).

    This threshold determines which scripts are considered “slow” – any script taking longer than this time will be logged. You can periodically review and adjust this threshold as needed, based on your application’s performance requirements.
  1. After modifying the settings, click on the “Save Configuration” button to enable the slow query monitoring on your server.
  2. After enabling and setting the threshold, wait for a few minutes to allow data collection.

    Open your website in a new browser tab and perform various actions such as posting new content or adding a new comment. After a few minutes, you’ll see a list of scripts that exceeded your set threshold:
  1. To get more information about a slow script, click on the “View Traces” button next to it, which will open a detailed view of the script’s execution path. This provides a stack trace of the slow script, showing you the exact path of execution.

When reading a trace log, start from the bottom of the trace and work your way up while looking for patterns or recurring files/functions that might be causing performance issues.

This helps you identify which parts of your application are contributing to the slow execution.

Let’s take a look at the above example. In this case, the trace shows the following information:

  • The main script file which was slow (index.php in this case).
  • The sequence of file inclusions or function calls that led to the slow execution.
  • The line numbers in each file where the next file was included or a function was called.

You can use this information to audit the source code of the website and identify which parts of the code are taking too long to execute.

Troubleshooting

If you are enabling slow script monitoring for the first time on a RunCloud Docker server, then you might run into some issues. To enable the slow script monitoring on your containerised server, you will need to re-initialise the server using the following steps:

  1. Change the PHP version of your web application from the RunCloud dashboard.
  2. Next, remove the PHP service from your Server by navigating to the services section and clicking “Remove from Stack” and then Deploy to save the changes.
  1. After removing the PHP stack, you need to add it again by clicking “Add to Stack” next to it and Deploy the stack again to re-initialise the stack.
  1. After adding the service again, you can go back to your web application settings and change the PHP version again to start using slow script monitoring on your server.