Improving Initial PHP ResponseTime for Uncached Idle Site

To improve site performance, a 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 way. These may include:

  • 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 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 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 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