Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
litespeed_wiki:php:slow_log_lsapi [2017/12/12 16:51]
Jackson Zhang created
litespeed_wiki:php:slow_log_lsapi [2017/12/12 20:54]
Robert Perper
Line 1: Line 1:
-====== Identify scripts that are slowing down your server ======+====== Identify scripts that are slow on your server ======
  
 When working with php, you will notice that your site is taking longer to load then expected. Learning why your site is loading so slow would be great. You can do an strace but sometimes that information is not always the best to read. When working with php, you will notice that your site is taking longer to load then expected. Learning why your site is loading so slow would be great. You can do an strace but sometimes that information is not always the best to read.
  
-If you are a PHP programmer, you must have used PHP’s error_log function sometime. But PHP itself does not provide a way to find out slowly executing ​scripts. Slow scripts are not the ones which break your site but they slow-down everything. With PHP-FPM, there is a slow_log function, by which developers can get a trace of what functions are running longer than a specified time+If you are a PHP programmer, you must have used PHP’s error_log function sometime. But PHP itself does not provide a way to identify slow scripts. ​
  
-LiteSpeed uses more faster LiteSpeed API (LSPHP) instead of PHP-FPM. How to trace the slow script with LSWS and LSPHP?+Slow scripts are not the ones which necessarily break your site but they can be slow in themselves and slow-down your server overall as they increase CPU overhead. ​ With PHP-FPM, there is a slow_log function, by which developers can get a trace of what functions are running longer than a specified time. 
  
-There is a directive, which can be placed at external application settings ​(WebAdmin console > Configuration > External App> Environment ​). +LiteSpeed uses the faster LiteSpeed API (LSPHPinstead of PHP-FPM ​What'​s the best way to identify slow scripts with LSWS and LSPHP?
  
-  ​LSAPI_SLOW_REQ_MSECS=30000+There is a directive, which can be placed at external application settings (WebAdmin console > Configuration > External App > Environment).  
 + 
 +  ​LSAPI_SLOW_REQ_MSECS=10000
    
 LSAPI_SLOW_REQ_MSECS:​ If set to a non-zero number, LiteSpeed Web Server will log requests into an error log file if a request takes longer than the specified number of milliseconds. This can help identify scripts that are slowing down your server. LSAPI_SLOW_REQ_MSECS:​ If set to a non-zero number, LiteSpeed Web Server will log requests into an error log file if a request takes longer than the specified number of milliseconds. This can help identify scripts that are slowing down your server.
Line 15: Line 17:
 {{ :​litespeed_wiki:​php:​lsapi_slow_req_msecs_conf_example.png?​600 |}} {{ :​litespeed_wiki:​php:​lsapi_slow_req_msecs_conf_example.png?​600 |}}
   ​   ​
 +Slow scripts are written to the stderr.log in the Litespeed log directory. ​ An example message would look like this:
 +
 +   ​[12/​Dec/​2017:​15:​37:​41] Slow PHP script: 10993 ms
 +     URL: GET /​wordpress/​index.php
 +     Query String:
 +     ​Script:​ /​home/​user/​olsws/​Example/​html/​wordpress/​index.php
  
 +There may be many of these messages. ​ Note that script slow-downs tend to appear in groups around the time of highest CPU load.  You should try to identify what is slowing down the script with the script author.
  • Admin
  • Last modified: 2017/12/12 21:15
  • by Lisa Clarke