This is an old revision of the document!


How to resolve high server load

If your server load is high (server loads that are <= the number of CPU Cores in your server are quite normal), you need to locate the bottleneck and make optimizations targeting it. Most of the time server load is caused by PHP processes and MySQL, not by LiteSpeed web server process itself. No Matter how fast LiteSpeed run, it has no control over how fast a PHP script can run, or how much memory a PHP script will consume. Hence generally troubleshooting server load issue is beyond LiteSpeed web server's configuration control and is beyond our support scope. Analysis of your Ddos attack is beyond our support scope as well unless you want to engage us through paid hourly support. However, we do provide the following troubleshooting tips for you when looking at server load issue.

  • Try to use our LSCache solutions to lower the load.
  • It is always good practice to use the top or atop command to check which processes are using a lot of CPU resources and figure out whether they are behaving normally.
  • If disk I/O is high, it is likely a disk I/O problem, which you should address. If you have more free memory available, you can move php sessions to /dev/shm.
  • Check the CPU idle percentage. If it is close to 0%, then your server is CPU-bound and you should try to reduce the CPU usage.
  • When CloudLinux used, you should try to use LVE limit to prevent resource consumption from any particular user.
  • Try PHP7 instead of PHP5 if your code is compatible with it.
  • Enable PHP opcode cache.
  • Check the real time stats for the number of PHP processes during peak time under Actions > Real-Time Stats > External Application, check In Use, Idle, and WaitQ. For shared hosting, if one user uses too many PHP processes while others only use a few, you may adjust PHP max concurrency setting to be a smaller number. See our PHP Concurrency wiki for more information on determining if PHP SuEXEC is used and how to reduce the max concurrency of PHP.
  • DDoS attack may push the server to high load. Check the number of concurrent users to see if it is normal: netstat -na | grep 80 | grep ESTA. To check concurrent connections sorted by IP, run the following: netstat -ntu | grep ESTABLISHED | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr. Sometime bad IP's can make quick connections and you end up with many time_waits and wont see it when just looking at established. In this case, you can run netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | awk '$1 >= 5 {print $0}' . This gives you the ability to see what IP's just connected and dropped and may need to be blocked. You can try some of the LSWS WAF features to mitigate DDoS attacks. If you can identify one or two IP causing the problem, you should find a way to limit the resource that one or two bad IP can consume. web server have no control over how fast a PHP script can run, or how much memory a PHP script will consume. Reasonably LVE limit by cloudLinux can help when someone abuses one account. If a server is under attack or being abused, you need to find a way to stop the attack or abuse, such as blocking bad IPs with a blacklist or using mod_security rule set. No matter how fast a web server can do, it can only handle the amount of traffic the backend (PHP and MySQL) can handle if everything has to be forwarded to the backend unless served from caches.
  • For control panel users, check your PHP configuration and make sure Apache and LiteSpeed have matching PHPs.
  • For cpanel/WHM user, disable PHP open_basedir feature.
  • Sometimes high load can be caused by poorly written PHP/SQL code and has to be fixed by your PHP Developers. Sometimes it is a MySQL-based problem, for example, you may have a missing index. To debug this, you may try to use mysqladmin and processlist. If you have spare RAM, trying to raise database cache pool/buffer may help. No web server configuration change can help such situations and they are beyond our support scope. You can even use strace to track your PHP processes: strace -tt -T -p <pid_of_a_php_process>
  top - 15:28:56 up 1 day, 17:58, 3 users, load average: 187.42, 143.52, 109.09
  PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  25713 mysql 20 0 15.3g 784m 9.9m S 197.1 0.9 29:13.90 /usr/sbin/mysqld --basedir=/usr --  datadir=/var/lib/mysql --plugin-
  30260 roan24pl 20 0 302m 103m 12m R 34.4 0.1 1:37.47 lsphp:/home/roan24pl/public_html/index.php
  30448 roan24pl 20 0 302m 103m 12m R 26.0 0.1 1:09.17 lsphp:/home/roan24pl/public_html/index.php
  30217 roan24pl 20 0 302m 102m 12m R 25.0 0.1 1:27.36 lsphp:/home/roan24pl/public_html/index.php
  28755 roan24pl 20 0 291m 92m 12m R 24.0 0.1 6:52.65 lsphp:/home/roan24pl/public_html/index.php
  • If you share session via MySQL database, you can try using memcached instead, to reduce the amount of MySQL queries.

Addressing the above may lower your server load. However, your situation may vary greatly. We recommend ordering our LiteSpeed premium support service for a professional review, fine tuning, and installation/enabling of necessary elements to reduce your server load and maximize site performance.

  • Admin
  • Last modified: 2019/05/14 20:35
  • by Jackson Zhang