Using xDebug to profile site performance on cPanel

Procédure

What is xDebug?

xDebug is a PHP extension used to debug sites. Among its features, it can be used to identify the source of slowness on a website.

How do I activate xDebug on cPanel?

From the PHP extensions selection tool in your cPanel control panel, activate the xDebug extension:

Using xDebug to profile site performance on cPanel

From theOptions tab, enable xdebug permanent profiling:

Using xDebug to profile site performance on cPanel

  • xdebug.mode is used to define xdebug's operating mode (in this case, profiling mode)
  • xdebug.output_dir allows you to specify the path where you are going to put the files generated by profiling (make sure that the folder exists on your FTP, otherwise xdebug will just forget the result when it detects that the folder is missing).
  • The format indicated on xdebug.profiler_output_name is used to indicate the format of the file name generated by profiling.
  • xdebug.start_with_request is used to define whether or not xDebug is activated automatically when PHP receives a request:
    • default: default value, depending on xdebug.mode:
      • xdebug.mode = false, xdebug.start_with_request equals no.
      • xdebug.mode = debug, xdebug.start_with_request is equivalent to trigger.
      • xdebug.mode = gcstats, xdebug.start_with_request is equivalent to no.
      • xdebug.mode = profile, xdebug.start_with_request equals yes.
      • xdebug.mode = trace, xdebug.start_with_request is equivalent to trigger.
    • yes: activate xDebug independently of xdebug.mode.
    • no: deactivates xDebug independently of xdebug.mode.
    • trigger: enables xDebug independently of xdebug.modewhen the XDEBUG_TRIGGER variable is present in the GET or POST request, in cookies or environment variables. This allows you to activate xDebug for specific cases, thus avoiding disrupting general traffic (for example, during debugging).

Once these settings are in place, go to the page you wish to profile in order to generate the profiling data. If all has gone well, you will see a new file in the folder you specified:

Using xDebug to profile site performance on cPanel

Each file will correspond to an HTTP request made.

Reading an xDebug profiling file with Webgrind

Once you have obtained your xDebug profiling file, install Webgrind on your hosting package to read its contents. To do this, download Webgrind and unzip it to a folder in your FTP space:

Using xDebug to profile site performance on cPanel

Then edit the config.php file to enter the path to the xdebug profiling files:

Using xDebug to profile site performance on cPanel

View profiling on the Webgrind interface

Then go to the URL https://www.votresite.com/webgrind (depending on where you have installed webgrind) and select a profiling event to open and click on"Update":

Using xDebug to profile site performance on cPanel

Once the file has been loaded, you will see a table like the one below:

Using xDebug to profile site performance on cPanel

The most important columns are: the function column which indicates the PHP function called, invocation count the number of calls made to it, total self cost the total time spent using it. You can then easily identify in the table the PHP functions that are causing your website to be slow, and modify the site to improve its performance.

Rate this article :

This article was useful to you ?

Article utileYes

Article non utileNo

Vous souhaitez nous laisser un commentaire concernant cet article ?

Si cela concerne une erreur dans la documentation ou un manque d'informations, n'hésitez pas à nous en faire part depuis le formulaire.

Pour toute question non liée à cette documentation ou problème technique sur l'un de vos services, contactez le support commercial ou le support technique

MerciMerci ! N'hésitez pas à poser des questions sur nos documentations si vous souhaitez plus d'informations et nous aider à les améliorer.


Vous avez noté 0 étoile(s)

Similar articles

1mn reading

How do I configure Cloudflare on a website hosted on cPanel?

3mn reading

How do you use Memcached on your cPanel website?

4mn reading

Using Redis as a persistent object cache for WordPress on cPanel

4mn reading

Speed up your site with Fastest Cache - Cache Varnish


Ask the LWS team and its community a question