When a WordPress site bursts past 200k concurrent visitors, the default LiteSpeed settings become a bottleneck, causing queue buildup and skyrocketing TTFB. This guide walks you through the exact kernel, systemd, and LiteSpeed tweaks that let a 8‑core VPS sustain 10k RPS with sub‑50 ms latency, all while keeping memory footprints under control. Mera Blogger
Why Traditional LiteSpeed Defaults Fail at Scale
Out‑of‑the‑box LiteSpeed ships with conservative maxConnections (5000) and maxSSLConnections (2000). In a high‑traffic WordPress environment these limits trigger connection throttling, especially when LSCache is disabled for dynamic content. Additionally, the default PHP worker pool (maxChildren=35) cannot keep up with the PHP‑FPM demand generated by Gutenberg blocks, REST API calls, and WooCommerce cart updates.
Architectural Overview
We’ll layer three optimization domains:
- Kernel & System Tuning: sysctl, ulimit, and IRQ affinity.
- LiteSpeed Core Settings: connection limits, listener tuning, and LSCache policies.
- PHP‑FPM / LSAPI Workers: dynamic scaling, opcache, and per‑worker memory caps.
Benchmark Matrix
1. Kernel & System Tweaks
sysctl -p /etc/sysctl.d/99-litespeed.conf after creation.# /etc/sysctl.d/99-litespeed.conf
net.core.somaxconn = 65535
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.ip_local_port_range = 1024 65535
net.core.netdev_max_backlog = 5000
fs.file-max = 2000000
vm.swappiness = 1
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5
Increase the open‑file limit for the LiteSpeed user:
# /etc/security/limits.d/litespeed.conf
litespeed soft nofile 200000
litespeed hard nofile 400000
2. LiteSpeed Core Configuration
All changes are made via the WebAdmin console (port 7080) or directly in /usr/local/lsws/conf/httpd_config.conf. After editing, run /usr/local/lsws/bin/lswsctrl restart.
listener Default {
address *:80
secure 0
maxConnections 25000
maxSSLConnections 20000
enableSSL 0
map example.com $VH_ROOT
}
listener SSL {
address *:443
secure 1
maxSSLConnections 20000
sslProtocol TLSv1.3
sslCipher HIGH:!aNULL:!MD5
map example.com $VH_ROOT
}
# Virtual Host tweaks
virtualhost example.com {
docRoot $VH_ROOT/html
enableGzip 1
enableCache 1
cachePolicy LSCache
cacheTTL 300
phpIniOverride /usr/local/lsws/conf/php.ini
}
LSCache Fine‑Tuning
Enable private caching for logged‑in users and set a 5‑minute TTL for dynamic fragments:
# /usr/local/lsws/conf/lscache.conf
CacheEnable public /
CacheEnable private /wp-admin/
CacheEnable private /wp-login.php
CacheTTL 300
CacheIgnoreHeaders Set-Cookie,Authorization
3. PHP‑FPM / LSAPI Worker Optimization
# /usr/local/lsws/conf/php.ini (partial)
opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0
# /usr/local/lsws/conf/lsphp.conf
lsapi:example {
env LSAPI_MAX_CHILDREN=200
env LSAPI_CHILDREN=200
env LSAPI_MAX_REQ=1000
env LSAPI_MAX_IDLE=30
env LSAPI_MAX_SPARE=20
env LSAPI_MIN_SPARE=10
env LSAPI_MAX_SPARE=30
env LSAPI_MAX_MEMORY=256M
}
4. Monitoring & Auto‑Scaling Hooks
Integrate lscpd metrics with Prometheus Node Exporter. Example alert for >80% worker queue depth:
# prometheus rule
- alert: LiteSpeedHighQueue
expr: lscpd_worker_queue_length{instance="web01"} > 80
for: 2m
labels:
severity: critical
annotations:
summary: "LiteSpeed worker queue high"
description: "Queue length {{ $value }} exceeds threshold on {{ $labels.instance }}"
5. End‑to‑End Deployment Checklist
- Apply sysctl and limits files, then
sysctl -p. - Restart LiteSpeed and verify
lswsctrl statusshows 25k connections. - Run
ab -n 50000 -c 5000 https://example.com/and confirm <90ms average latency. - Enable Prometheus node exporter and set up Grafana dashboards for LSCache hit ratio.
FAQs
How many LiteSpeed workers should I allocate for 8 CPU cores?
Start with LSAPI_MAX_CHILDREN = cores * 25 (e.g., 200 for 8 cores) and let the auto‑scale thresholds adjust upward during traffic spikes.
Is LSCache safe for WooCommerce carts?
Enable CacheEnable private /wp-admin/ and set CacheIgnoreHeaders Set-Cookie for cart‑related endpoints. This keeps cart sessions dynamic while caching the rest of the page.
What kernel parameters impact SYN flood resilience?
Increase net.ipv4.tcp_max_syn_backlog to 4096 and enable net.ipv4.tcp_syncookies. Pair with somaxconn 65535 for maximum listen queue depth.
Ready to Power Your WordPress Site with Enterprise‑Grade LiteSpeed?
Deploy the tuned stack on a high‑performance cloud VPS, monitor with Prometheus, and watch your traffic scale without a hitch.
