[solved] lsphp command using 100+% cpu usage

#1
Hii, I have VPS with litespeed webserver everything is working fine but sometimes lsphp commands are using 100+% cpu usage when I saw with top command. I want to know why it is using cpu resources at high level. I am posting the screenshot of command line here. Please help me and look into the matter.
Load average is 4.27, 4.20, 4.78
ss.png
 

Pong

Administrator
Staff member
#2
100% only means one core. You may have many cores on the server. PHP sometimes could be very heavy depend on your appalication, nothing to do with LiteSpeed Web Server.

You should enable cache for atestkqg domain, which will try to avoid PHP processes.
 

Pong

Administrator
Staff member
#4
maybe I did not clarify enough, High PHP usage is something on the PHP application, not on LiteSpeed, but LScache can help/mitigate such situation.
What application do you use? Is it a wordpress site? What's the URL?
Did you verify the header to ensure cthe ache is working?
 
#5
It is codingniter website develpped in php and I found nothing in php code which can cause the issue even everything was working fine on a previous shared server.
 

NiteWave

Administrator
#9
this will be more helpful to know which file it's reading ... endless reading likely a big problem.
you can "lsof -p pid" to know which files the lsphp has opened.
 
#11
Screenshot_1.png
lsphp (or lsphpXX, where XX is a version number) is a PHP handler used by the LiteSpeed Web Server, and high CPU usage can be caused by a number of factors, including inefficient or resource-intensive PHP scripts, misconfiguration, or insufficient server resources.
Here are some steps you can take to reduce lsphp high CPU usage:
  1. Optimize your PHP scripts: Review your PHP code and identify any inefficient loops, database queries, or other performance bottlenecks. Consider using caching solutions like opcode caching (e.g., APC, OPcache) or object caching (e.g., Memcached, Redis) to speed up your application.
  2. Increase server resources: If your server is underpowered, consider upgrading to a higher CPU or adding more RAM. This can help to reduce CPU usage and improve overall performance.
  3. Tune lsphp configuration: Review your lsphp configuration to ensure that it is optimized for your application. You can adjust settings such as the number of workers, maximum connections, and maximum requests per process.
  4. Enable LiteSpeed Cache: LiteSpeed Cache is a server-side caching solution that can dramatically improve website performance and reduce CPU usage. Consider enabling LiteSpeed Cache for your website.
  5. Monitor server performance: Use monitoring tools like top, htop, or atop to keep an eye on CPU usage and identify any processes that are consuming excessive resources. This can help you to quickly identify and address any issues.
Remember that reducing CPU usage is a continuous process that requires ongoing optimization and monitoring. By following these steps, you should be able to reduce lsphp high CPU usage and improve overall server performance.
 
Top