tune(litespeed): bump opcache 32→64 MB / 4000→8000 files + add per-site override
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 1m37s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 1m42s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 1m50s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m51s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 3m18s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 2m21s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 3m49s
Cloud Apache Container / Build-FPM-Images (74) (push) Successful in 2m0s
Cloud Apache Container / Build-FPM-Images (80) (push) Successful in 1m44s
Cloud Apache Container / Build-FPM-Images (81) (push) Successful in 1m30s
Cloud Apache Container / Build-FPM-Images (82) (push) Successful in 1m48s
Cloud Apache Container / Build-FPM-Images (83) (push) Successful in 1m40s
Cloud Apache Container / Build-FPM-Images (84) (push) Successful in 1m58s
Cloud Apache Container / Build-FPM-Images (85) (push) Successful in 2m15s
Cloud Apache Container / Build-LiteSpeed-Images (81) (push) Successful in 29s
Cloud Apache Container / Build-LiteSpeed-Images (82) (push) Successful in 29s
Cloud Apache Container / Build-LiteSpeed-Images (83) (push) Successful in 29s
Cloud Apache Container / Build-LiteSpeed-Images (84) (push) Successful in 29s
Cloud Apache Container / Build-LiteSpeed-Images (85) (push) Successful in 29s
Cloud Apache Container / Build-Shared-httpd (push) Successful in 26s

32M/4000 was too aggressive for heavy WP+Divi+WC sites: 3000+4000 unique
PHP files each blow through max_accelerated_files, causing constant
eviction + recompilation thrash. Manifested 2026-06-03 as ~40% sustained
CPU on alphaoneaminos and 5378 oom_kills/9h on brain-jar.

64M/8000 fits Divi + WC + WP core bytecode without eviction. N lsphp ×
64 MB ≈ 512 MiB shmem worst case — still under the per-instance setUIDMode
fan-out from the original 128M problem (which was 1+ GiB).

Per-site override (OPCACHE_MEMORY_MB / OPCACHE_MAX_FILES env vars) lets the
panel push down for low-traffic sites or up for outliers without rebuilding
the image. WHP panel UI ships in a follow-up commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-03 06:21:37 -07:00
parent 87f154cdc8
commit cfdaae116a
2 changed files with 33 additions and 8 deletions

View File

@@ -25,14 +25,26 @@ session.gc_divisor = 1000
session.gc_maxlifetime = 1440
opcache.enable = 1
; Sized small because shmem is per-process-RSS on Linux cgroups (vs PHP-FPM's
; COW-shared model). At 128 MB × N lsphp instances we were hitting 800+ MiB
; shmem on heavy WP sites; 32 MB × N fits comfortably and still caches ~4000
; scripts (covering Divi + WC + WP core easily). Bump per-site via WHP user
; variables (OPCACHE_MEMORY_MB) if a high-traffic site needs more.
opcache.memory_consumption = 32
opcache.interned_strings_buffer = 8
opcache.max_accelerated_files = 4000
; Sized to fit Divi + WooCommerce + WP core comfortably without eviction
; thrash. Per-instance because shmem is per-process-RSS on Linux cgroups
; (vs PHP-FPM's COW-shared model — one lsphp PARENT per httpd worker in
; OLS, each with its own opcache segment).
;
; Sizing history:
; 128 MB / 10000 files (original): blew 800+ MiB shmem under setUIDMode 2
; because that gave 8+ lsphp instances each at 128 MB → 1+ GiB shmem.
; 32 MB / 4000 files (2026-06-02): solved the shmem problem but caused
; opcache eviction thrash on Divi/WC sites (3000+4000 unique PHP files
; each); manifested as ~40% sustained CPU on alphaoneaminos and
; elevated OOM cycling on brain-jar (5378 oom_kills/9h on 2026-06-03).
; 64 MB / 8000 files (current): fits Divi+WC bytecode without eviction;
; N lsphp × 64 MB ≈ 512 MiB shmem worst case, still acceptable.
;
; Override per-site via OPCACHE_MEMORY_MB / OPCACHE_MAX_FILES env vars
; (panel: Advanced Tuning → OpCache size) for outliers.
opcache.memory_consumption = 64
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 8000
opcache.revalidate_freq = 60
opcache.enable_cli = Off

View File

@@ -74,6 +74,19 @@ if [ -n "$SCAN_DIR" ]; then
error_log = /home/${user}/logs/php-fpm/error.log
log_errors = On
EOF
## Per-site opcache override (panel: Advanced Tuning → OpCache size).
## Falls back to the global lsphp-overrides.ini values (64 MB / 8000 files)
## when the env vars aren't set. Numeric range/sanity is enforced in the
## WHP panel before the env var lands here.
if [ -n "${OPCACHE_MEMORY_MB:-}" ] || [ -n "${OPCACHE_MAX_FILES:-}" ]; then
{
echo "; rendered at container start by entrypoint-litespeed.sh"
echo "; per-site override from WHP whp.sites.opcache_*_override"
[ -n "${OPCACHE_MEMORY_MB:-}" ] && echo "opcache.memory_consumption = ${OPCACHE_MEMORY_MB}"
[ -n "${OPCACHE_MAX_FILES:-}" ] && echo "opcache.max_accelerated_files = ${OPCACHE_MAX_FILES}"
} > "$SCAN_DIR/99-user-opcache.ini"
fi
fi
## ---- ownership: OLS runs as $user end-to-end (server-level user set by