From cfdaae116a0ff903f44b2484cdad9ceb9ff9eb26 Mon Sep 17 00:00:00 2001 From: jknapp Date: Wed, 3 Jun 2026 06:21:37 -0700 Subject: [PATCH] =?UTF-8?q?tune(litespeed):=20bump=20opcache=2032=E2=86=92?= =?UTF-8?q?64=20MB=20/=204000=E2=86=928000=20files=20+=20add=20per-site=20?= =?UTF-8?q?override?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- configs/litespeed/lsphp-overrides.ini | 28 +++++++++++++++++++-------- scripts/entrypoint-litespeed.sh | 13 +++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/configs/litespeed/lsphp-overrides.ini b/configs/litespeed/lsphp-overrides.ini index 8fd7f69..881157a 100644 --- a/configs/litespeed/lsphp-overrides.ini +++ b/configs/litespeed/lsphp-overrides.ini @@ -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 diff --git a/scripts/entrypoint-litespeed.sh b/scripts/entrypoint-litespeed.sh index 05e8eca..fd4c6a5 100644 --- a/scripts/entrypoint-litespeed.sh +++ b/scripts/entrypoint-litespeed.sh @@ -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