Notes on Tuning a ‘Legacy’ Stack

Versuch einer Selbstdokumentation

Assuming RHEL8 and the like, enable zswap and huge page support. Compile httpd and php from source with gcc12: scl enable gcc-toolset-12 bash.

Configure httpd with mod_brotli. Configure php with fpm, opcache and extensions required by CMS/plugins. Configure both with CFLAGS=‘-O2 -march=native’.

Build php with PGO: make prof-gen; sapi/cgi/php-cgi -T 100 /path/to/index.php >/dev/null (ie no ‐‐disable-cgi); make prof-clean; make prof-use && make install. Adjust path to php’s bin directory in .bash_profile. Compile pear and pecl extensions: php go-pear.phar; pecl install apcu; dnf ‐‐enablerepo=remi install ImageMagick7 (assuming RHEL8/9 etc, where it isn’t in EPEL yet); pecl install imagick. Enable opcache.huge_code_pages.

Adjust reverse proxy setup:
<FilesMatch “\.php$”>

SetHandler “proxy:unix:/path/to/php-fpm.sock|fcgi://localhost/”

<Proxy “fcgi://localhost/” enablereuse=on max=10>
Assuming event MPM and pm=static, let ServerLimit >= 10 * MaxRequestWorkers / ThreadsPerChild. Set pm.max_children according to RAM.

Use rpm packages from Mysql. Install and enable jemalloc (EPEL). Set large-pages=ON; set transparent huge pages to madvise. In case of mmap alloc error, adjust unit configuration so it starts before php. Set oom_score_adj to -800. Prune autoload options in Workbench.


*  *