Optimize Apache & PHP-FPM memory for lower idle usage
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 2m31s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 1m54s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 1m51s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m52s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 2m39s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 1m58s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 1m51s

Switch PHP-FPM from pm=dynamic to pm=ondemand (zero idle workers),
auto-detect container memory via cgroups to calculate appropriate
limits, and generate Apache MPM config at runtime. All tuning values
are now overridable via environment variables.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-25 18:52:15 -08:00
parent a153385d8f
commit 87c4f2befc
5 changed files with 144 additions and 19 deletions

View File

@@ -0,0 +1,17 @@
#!/bin/bash
# Generate Apache MPM event tuning config at runtime using detect-memory.sh values.
cat <<EOF > /etc/httpd/conf.d/mpm-tuning.conf
<IfModule mpm_event_module>
StartServers ${APACHE_START_SERVERS}
MinSpareThreads ${APACHE_MIN_SPARE_THREADS}
MaxSpareThreads ${APACHE_MAX_SPARE_THREADS}
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers ${APACHE_MAX_REQUEST_WORKERS}
ServerLimit ${APACHE_SERVER_LIMIT}
MaxConnectionsPerChild ${APACHE_MAX_CONNECTIONS_PER_CHILD}
</IfModule>
EOF
exit 0