LSAPI, the LiteSpeed Server API, is how LiteSpeed Web Server runs PHP through its own PHP binary, lsphp. On a LiteSpeed server it is the right handler for the great majority of WordPress and PHP sites: LiteSpeed starts and supervises the PHP workers itself, and there is exactly one process tree to reason about. PHP-FPM is a separate PHP service that LiteSpeed reaches through a proxy, and it is the better choice in a short list of cases. Those are an Nginx tier you are not rewriting, hundreds of mostly idle sites that need ondemand pools, monitoring already built on the FPM status page and slow log, a per-pool php.ini layout you depend on, or PHP shipped as its own container image. The sections below give the evidence behind that verdict: the architecture, the sizing arithmetic for both handlers, a fair benchmark method, and how to switch on cPanel and roll back.
What you’ll accomplish
- Identify which PHP handler is actually serving requests on your server right now.
- Size a worker count for LSAPI and for PHP-FPM from the same memory budget, so the two are comparable.
- Read queue depth on both handlers instead of guessing from requests per second.
- Benchmark the two on identical hardware without accidentally measuring your page cache.
- Switch handlers on cPanel and reverse the change in one command if the numbers do not hold up.
Prerequisites
Root shell access on a cPanel/WHM server running LiteSpeed Enterprise or OpenLiteSpeed, PHP 8.1 or newer through EasyApache 4, and a maintenance window — every change here restarts PHP. On LiteSpeed Enterprise the handler is set per PHP version in WHM MultiPHP Manager; on OpenLiteSpeed there is no MultiPHP integration and external applications are declared by hand in httpd_config.conf. The free LiteSpeed Enterprise licence caps worker processes and server memory well below a paid licence, so the concurrency ceiling you measure on a free licence is not the ceiling of the software. Paths below use ea-php82 and lsphp82; substitute your version. Commands assume AlmaLinux or Rocky Linux with systemd and dnf.
How it works
LSAPI is a persistent-process protocol. LiteSpeed itself spawns an lsphp parent for each vhost user, drops privileges to that user through its suEXEC implementation, and lets that parent fork children to handle concurrent requests. Process management, user separation and connection reuse all live inside one supervisor. When a worker overruns LSAPI_MAX_PROCESS_TIME or its memory limits, LiteSpeed is the process that notices and kills it, and the connection it was holding is accounted for in the same place.
PHP-FPM inverts that. The FPM master is a separate daemon with its own systemd unit and its own pools; LiteSpeed reaches it as an external application, speaking FastCGI over a UNIX socket or TCP. The web server does not own the lifecycle. A systemctl restart php82-php-fpm kills in-flight requests that LiteSpeed still believes are running, and LiteSpeed will return 503 until the socket comes back. A runaway worker is reaped by FPM’s request_terminate_timeout, not by the web server, and memory accounting lands under the FPM cgroup rather than under the user’s process tree.
That difference in where the supervision boundary sits explains most of the practical trade-offs. It is not mainly about protocol overhead — the per-request saving from LSAPI framing is real but small next to a WordPress page that spends 80 ms in PHP. It is about who restarts what, and where you look when a site starts queueing.
What LSAPI wins on is the count of moving parts. There is no second daemon to keep alive, no socket permission problem to solve, no pool file to keep in sync with a vhost file. LiteSpeed recycles workers on its own schedule, per-request overhead on PHP-heavy pages is lower because the connection to the child is already open, and cPanel MultiPHP drives the whole thing from one screen. When a site queues, .rtreport tells you which external application is short of workers, and that is the only place you have to look.
What PHP-FPM wins on is everything that comes from PHP being its own service. An Nginx tier already in front of LiteSpeed, or in front of nothing, keeps working untouched. A shop with dashboards and alerts already fed by pm.status_path and the slow log keeps its tooling. ondemand pools let hundreds of quiet sites hold zero resident workers each and start one only when a request arrives — LSAPI has LSAPI_MAX_IDLE but not that same idle-to-zero shape per vhost. A per-pool php.ini layout, with php_admin_value overrides per application, has no direct LSAPI equivalent. And in a containerised deployment where PHP is a separate image with its own release cadence, FPM is the only entry point that makes sense.
Step-by-step
1. Confirm which handler is serving requests today. Do not trust the WHM screen alone; look at the processes.
ps -eo user,rss,comm | grep -E 'lsphp|php-fpm' | grep -v grep | head
/usr/local/cpanel/bin/whmapi1 php_get_vhost_versions | grep -E 'vhost|version|php_fpm'
Expect lsphp processes owned by individual cPanel users if LSAPI is active, or php-fpm processes owned by root plus per-user children if PHP-FPM is active. Seeing both means two backends are installed and only one is receiving traffic.
2. Decide with the criteria, not with a benchmark. The handler choice is settled by architecture in almost every case; the benchmark only confirms it.
3. Size the worker count from a memory budget. Both handlers need the same arithmetic. Measure real resident size first rather than trusting memory_limit.
ps -eo rss,comm | grep -E 'lsphp|php-fpm' | awk '{s+=$1; n++} END {print "avg RSS MB:", s/n/1024, "samples:", n}'
free -m | awk '/^Mem:/ {print "total MB:", $2, "available MB:", $7}'
A typical WordPress worker with a few plugins reports 70–110 MB resident.
On a 16 GB box, reserve 4 GB for MariaDB and 2 GB for the OS, LiteSpeed and backups, which leaves roughly 10 GB for PHP. At 80 MB per worker that is 128 workers. Use that same 128 for both handlers, or the comparison is meaningless.
4. Configure LSAPI concurrency. On cPanel, the lsphp external application lives in /usr/local/lsws/conf/httpd_config.conf.
extprocessor lsphp {
type lsapi
address uds://tmp/lshttpd/lsphp.sock
maxConns 128
env PHP_LSAPI_CHILDREN=128
env PHP_LSAPI_MAX_REQUESTS=1000
env LSAPI_AVOID_FORK=200M
env LSAPI_MAX_IDLE=60
initTimeout 60
retryTimeout 0
persistConn 1
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 400
procHardLimit 500
}
PHP_LSAPI_CHILDREN (also accepted as LSAPI_CHILDREN) is the ceiling on concurrent children and must match maxConns — a mismatch means LiteSpeed queues connections a worker was willing to take. PHP_LSAPI_MAX_REQUESTS (also accepted as LSAPI_MAX_REQS) recycles a child after that many requests, which is the cheap defence against slow leaks. LSAPI_AVOID_FORK keeps idle children resident up to the given memory figure instead of tearing them down between bursts. Apply with:
/usr/local/lsws/bin/lswsctrl restart
Expect [OK] Send SIGUSR1 to ... or litespeed: pid=..., then lsphp processes reappearing within a few seconds.
5. Configure a PHP-FPM pool if the decision tree sent you there. cPanel generates per-domain pools under /opt/cpanel/ea-php82/root/etc/php-fpm.d/, one .conf per domain. Do not hand-edit those files: /usr/local/cpanel/scripts/php_fpm_config --rebuild overwrites them. Set system defaults in /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml, or per-domain values in /var/cpanel/userdata/<user>/<domain>.php_fpm.yaml, then rebuild.
pm = ondemand
pm.max_children = 128
pm.max_requests = 1000
pm.process_idle_timeout = 30s
request_terminate_timeout = 300
request_slowlog_timeout = 5s
slowlog = /opt/cpanel/ea-php82/root/usr/var/log/slow.log
pm.status_path = /fpm-status
pm = static holds every worker resident and is the fastest under steady load; dynamic keeps a floor of idle workers; ondemand starts at zero and lets pm.process_idle_timeout retire workers, which is the reason FPM wins on hundreds of quiet sites. The memory arithmetic behind that ceiling is worked through in PHP-FPM max children calculation.
/usr/local/cpanel/scripts/php_fpm_config --rebuild
systemctl restart ea-php82-php-fpm
systemctl is-active ea-php82-php-fpm
Expect active.
6. Check OPcache on both, because the segments do not line up. OPcache is shared memory attached to a process tree, so under LSAPI each user’s lsphp parent carries its own segment, and 60 busy accounts on a 128 MB setting is 7.5 GB of OPcache before a single request runs. Under PHP-FPM the segment belongs to the master, so a pool restart drops it and the next requests recompile every file. Warm-up is therefore visible after every FPM reload and only after a user’s first request under LSAPI.
/opt/cpanel/ea-php82/root/usr/bin/php -i | grep -E 'opcache.(enable|memory_consumption|max_accelerated_files|validate_timestamps)'
Expect opcache.enable => On => On and a memory_consumption you have multiplied by your expected number of live parents.
7. Benchmark honestly, or not at all. Same hardware, same PHP build, same OPcache settings, cache warmed by a few requests first, and a real WordPress page — never phpinfo(), and never a page LSCache is serving, or you will benchmark the cache and conclude the handler is fast.
curl -sI 'https://example.com/shop/?nocache=1' | grep -iE 'x-litespeed-cache|x-lsadc-cache'
for c in 10 25 50 100; do
wrk -t4 -c"$c" -d30s 'https://example.com/shop/?nocache=1' | grep -E 'Requests/sec|Latency'
done
Expect the cache header to read miss or be absent. Requests per second will flatten well before your worker ceiling; the concurrency where p99 latency turns upward is the number that matters.
8. Read queue depth, not throughput. This is where the two handlers diverge honestly.
grep EXTAPP /tmp/lshttpd/.rtreport
curl -s 'http://127.0.0.1/fpm-status?full' | grep -E 'listen queue|active processes|max children reached'
Under LSAPI, WAITQUE_DEPTH: 0 means no request waited for a worker. Under FPM, a non-zero listen queue or a rising max children reached means the same thing.
9. Switch handlers on cPanel, and know the rollback. One command each way, per PHP version.
/usr/local/cpanel/bin/whmapi1 php_set_handler version=ea-php82 handler=lsapi
/usr/local/cpanel/bin/whmapi1 php_get_handlers | grep -A3 ea-php82
Expect current_handler: lsapi. The reverse is handler=cgi combined with per-domain FPM, and the full sequence including the LiteSpeed side is covered in switching the lsphp handler on cPanel. Take a copy of /usr/local/lsws/conf/httpd_config.conf before you start; that file plus the whmapi1 call is the whole rollback.
Validate it works
Confirm the handler, then confirm PHP is actually being reached through it.
/opt/cpanel/ea-php82/root/usr/bin/lsphp -v | head -1
ps -eo user,comm | grep -c lsphp
curl -s -o /dev/null -w '%{http_code} %{time_total}\n' 'https://example.com/?nocache=1'
Expect a first line ending in (litespeed), a non-zero lsphp count owned by real cPanel users, and a 200 with a total time in the same range you measured in step 7. Re-run step 8 under live traffic an hour later: a queue depth that stays at zero at peak means the sizing holds.
Troubleshooting
503 immediately after switching to PHP-FPM. LiteSpeed cannot open the FPM socket. FPM writes it as root:root mode 0660 by default while lshttpd runs as nobody. Set listen.owner, listen.group and listen.mode in the pool so the LiteSpeed user can write to it, restart FPM, then restart LiteSpeed.
Requests queue while memory sits idle. maxConns and PHP_LSAPI_CHILDREN disagree, so LiteSpeed refuses connections a worker would have accepted. Set them to the same number and restart. Confirm with WAITQUE_DEPTH in .rtreport returning to zero.
Memory exhaustion after raising the child count on a shared box. Under LSAPI every user gets a parent and every parent gets an OPcache segment, so worker count multiplies by account count, not by one. Lower opcache.memory_consumption, or lower PHP_LSAPI_CHILDREN and let LSAPI_MAX_IDLE retire quiet children.
Pool edits keep disappearing on cPanel. You edited a file under /opt/cpanel/ea-php82/root/etc/php-fpm.d/ directly. cPanel regenerates that directory. Put the values in the YAML defaults or the per-domain YAML and run --rebuild.
LSAPI looks slower than FPM in the benchmark. Usually the FPM run was served from LSCache and the LSAPI run was not, or the two runs used different opcache.validate_timestamps settings. Re-check the cache header on every run and diff the two php -i outputs before believing the number.
When this is the wrong approach
If PHP is a container image with its own release cycle, the handler question is already answered — FPM is the only sensible entry point and LiteSpeed is a reverse proxy in front of it. If your bottleneck is database queries or a plugin doing remote HTTP calls on every page load, neither handler changes anything and worker tuning only lets you queue more requests against the same slow backend. And if the site is fully served from LSCache, the PHP handler is close to irrelevant to visitor-facing latency; spend the time on cache hit ratio instead. On OpenLiteSpeed there is no MultiPHP integration at all, so treat the cPanel steps here as inapplicable and configure the external application directly, following the LiteSpeed documentation and the PHP FPM installation manual.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.