Differences

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

Link to this comparison view

litespeed_wiki:php:improve_initial_php_response_without_cache [2020/01/15 20:16]
Jackson Zhang created
litespeed_wiki:php:improve_initial_php_response_without_cache [2020/01/15 20:49]
Lisa Clarke Copyediting
Line 1: Line 1:
-====== ​How to improve initial ​PHP response without cache for an idle site? ====== +====== ​Improving Initial ​PHP ResponseTime  ​for Uncached Idle Site ====== 
-To improve ​the site performance, ​the key step is to enable cache to avoid PHP processes. However, ​the cache may not be able to use for some situations or applications,​ and you will need to improve PHP performance ​by enabling opcode cache, choosing higher PHP version which has better performance,​ disabling ''​xdebug''​ and ''​snmp''​ php modules if they were enabled accidentally or increacing ''​PHP suEXEC Max Conn''​ when WaitQ is frequently higher than 0, etc. You can check [[https://​www.litespeedtech.com/​support/​wiki/​doku.php/​litespeed_wiki:​php:​improve-performance|this wiki]] on how to improve PHP performance in detail. +To improve site performance, ​key step is to enable cache and avoid invoking ​PHP altogether. However, ​caching ​may not be available ​for some situations or applications,​ and you will need to improve PHP performance some other wayThese may include:
- +
-For an uncachable site, if it is not busy and has been idle for some time, when a new visitor comes in, the initial PHP loading time could be very slow while the second request is fast ​Assuming the opcode cache enabled for the site, what could be the reason to make initial PHP response time slow?  +
- +
-One possible reason could be due to the PHP startup time. You may or may not knowPHP processes are dynamically spawned and it may take time to start a PHP process. [[https://​www.litespeedtech.com/​docs/​webserver/​config/​php#​extMaxIdleTime|''​Max Idle Time''​]] will control how long the php will keep alive for that site when idle. If such an initial response is critical to your site, you may want to change ​ "Max Idle time" to let it running loner, for example, changing from "​60"​ to "​86400"​ (1 day) through LSWS Web Admin Console under ''​PHP''​ tab to reduce the PHP startup time. +
- +
-The other possible reason could be CloudLinux LVE limits IO/IOPS. When an account idle for while, data is not in kernel cache anymore, PHP need to load many things from disk, the IO limits slow PHP down when loading file from disk. That's the main factor that a page will take a long time to load if idle for a while. In this situation, you can try raising the IO limit or disable the IO limit.+
  
 +  * enabling opcode cache
 +  * choosing a higher PHP version with better performance
 +  * disabling ''​xdebug''​ and ''​snmp''​ PHP modules if they were enabled accidentally
 +  * increasing ''​PHP suEXEC Max Conn''​ when WaitQ is frequently higher than 0
 +   
 +See [[litespeed_wiki:​php:​improve-performance|this wiki]] to learn more about improving PHP performance in detail.
  
 +For an uncachable site, that is not busy and has been idle for some time, when a new visitor comes in, the initial PHP load time could be very slow while the second request is fast. Assuming the opcode cache is enabled for the site, this is likely because PHP processes are being dynamically spawned, which may take time.
  
 +There are two settings that may be adjusted to minimize the impact of spawning new PHP processes: Max Idle Time, and CloudLinux LVE IO Limit.
  
 +===== Max Idle Time =====
 +**[[https://​www.litespeedtech.com/​docs/​webserver/​config/​php#​extMaxIdleTime|Max Idle Time]]** controls how long PHP will keep alive for that site when the site is idle. If a fast initial response is critical to your site, you may want to increase it so that PHP can run longer. For example, navigate to **LiteSpeed WebAdmin Console > PHP** , and change **MaxIdleTime** from ''​60''​ seconds to ''​86400''​ (1 day) . Then, PHP will only have to start up once per day, at most, where previously it would require a restart any time after 60 seconds had passed.
  
 +===== CloudLinux LVE IO Limit =====
 +CloudLinux LVE limits IO/IOPS. When an account is idle for while, data is not in the kernel cache anymore, and PHP needs to load many things from disk. IO limits slow PHP down when it is loading a file from disk. That's the main factor that causes a page to take a long time to load after a period of idelness. Try raising the IO limit or disabling it altogether to alleviate this problem.
  
  • Admin
  • Last modified: 2020/01/15 20:49
  • by Lisa Clarke