Troubleshooting: Too many LSPHP processes on DA when using OLS

You are here:
< Back

How to Reduce LSPHP Processes

A user reported that there were too many LSPHP processes running with DirectAdmin while OpenLiteSpeed was being used. There are a few different approaches to resolve this. Two configurations in particular affect the process count: LSPHP max connections for each user and OpenLiteSpeed workers.

First, you may want to enable LSCache and verify the cache hit header.

Second, the total max LSPHP number for each user will be LSPHP SuEXEC max connections * the number of OpenLiteSpeed workers. Reducing LSPHP SuEXEC max connections, or the number of OpenLiteSpeed workers, or both, should reduce the total number of LSPHP processes.

 

Problem

For this troubleshooting case:

nproc
6
ps -ef | grep openlitespeed
  root 2998 1 1 18:20 ? 00:00:01 openlitespeed (lshttpd - main)
  root 3007 2998 0 18:20 ? 00:00:00 openlitespeed (lscgid)
  apache 3010 2998 1 18:20 ? 00:00:02 openlitespeed (lshttpd - #01)
  apache 3011 2998 2 18:20 ? 00:00:02 openlitespeed (lshttpd - #02)
  apache 3012 2998 2 18:20 ? 00:00:02 openlitespeed (lshttpd - #03)
  apache 3013 2998 2 18:20 ? 00:00:02 openlitespeed (lshttpd - #04)
  apache 3014 2998 2 18:20 ? 00:00:03 openlitespeed (lshttpd - #05)
  apache 3015 2998 2 18:20 ? 00:00:03 openlitespeed (lshttpd - #06)

The server only has 8 cores, but 6 OpenLiteSpeed workers are enabled, which is a little too much. One or two LiteSpeed workers are recommended for a 8 core server.

Given the LSPHP SuEXEC max connection settings at /usr/local/lsws/conf/httpd-phplimits.conf

maxConns 100
env PHP_LSAPI_CHILDREN=100

100 * 6 = 600 LSPHP max processes for each user.  If this is only for a dedicated VPS, it should be okay. However, it will probably be too much for a shared hosting server if you have a lot of user accounts.

 

Solution

Reduce LSPHP SuEXEC max connections from 100 to 10,

maxConns 10
env PHP_LSAPI_CHILDREN=10

This changes the number of max connections and children per worker.

Then reduce OpenLiteSpeed workers to 1

vi /usr/local/lsws/conf/httpd-defaults.conf
httpdworkers 1
/usr/local/lsws/bin/lswsctrl restart
ps -ef | grep openlitespeed
  root 4867 1 0 14:50 ? 00:00:19 openlitespeed (lshttpd - main)
  root 4874 4867 0 14:50 ? 00:00:00 openlitespeed (lscgid)
  apache 4878 4867 11 14:50 ? 00:07:05 openlitespeed (lshttpd - #01)

This makes it so you only have 1 worker process..

Now you should have reduced LSPHP processes to a max of 10*1=10