Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHRAS-3387 php fpm optimization #4364

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ MAX_INPUT_TIME=60
# @run
REQUEST_TERMINATE_TIMEOUT=300s

# Maximum amount of memory a script may consume (128MB)
# http://php.net/memory-limit
FPM_MEMORY_LIMIT=2048M
PHP_CLI_MEMORY_LIMIT=2048M


# Php Opcache status. See [opcache Php documentation|
# https://www.php.net/manual/en/intro.opcache.php].
# Avalaible values: "0" | "1"
Expand Down Expand Up @@ -288,6 +294,40 @@ SESSION_SAVE_PATH=tcp://redis-session:6379
#only works if the application is under ssl protection
COOKIE_SECURE=false

# FPM
# Choose how the process manager will control the number of child processes.
# Possible Values:
# static - a fixed number (pm.max_children) of child processes;
# dynamic - the number of child processes are set dynamically based on the
FPM_PM_TYPE=dynamic

# FPM
# The number of child processes to be created when pm is set to 'static' and the
# maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
FPM_MAXCHILDREN=9

# FPM
# The number of child processes created on startup.
# Note: Used only when pm is set to 'dynamic'

FPM_STARTSERVERS=3

# FPM
# The desired minimum number of idle server processes.
# Note: Used only when pm is set to 'dynamic'
# Note: Mandatory when pm is set to 'dynamic'
FPM_MINSPARESERVER=2

# FPM
# The desired maximum number of idle server processes.
# Note: Used only when pm is set to 'dynamic'
# Note: Mandatory when pm is set to 'dynamic'
FPM_MAXSPARESERVER=4

# FPM
# The number of requests each child process should execute before respawning.
FPM_MAX_REQUESTS=1000

# --- MySQL settings ---------------------------------------------------------------------------------------------------

# MySQL root password.
Expand Down
22 changes: 21 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- PHRASEANET_ADMIN_ACCOUNT_ID
- PHRASEANET_ADMIN_ACCOUNT_EMAIL
- PHRASEANET_ADMIN_ACCOUNT_PASSWORD
Expand Down Expand Up @@ -254,7 +255,13 @@ services:
- SESSION_SAVE_HANDLER
- SESSION_SAVE_PATH
- PHRASEANET_MAINTENANCE

- FPM_MEMORY_LIMIT
- FPM_PM_TYPE
- FPM_MAXCHILDREN
- FPM_STARTSERVERS
- FPM_MINSPARESERVER
- FPM_MAXSPARESERVER
- FPM_MAX_REQUESTS
volumes:
- ${PHRASEANET_CONFIG_DIR}:/var/alchemy/Phraseanet/config:rw
- ${PHRASEANET_LOGS_DIR}:/var/alchemy/Phraseanet/logs:rw
Expand Down Expand Up @@ -284,6 +291,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -353,6 +361,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -407,6 +416,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -567,6 +577,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -620,6 +631,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -726,6 +738,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -885,6 +898,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -941,6 +955,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -1047,6 +1062,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -1100,6 +1116,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -1153,6 +1170,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -1206,6 +1224,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down Expand Up @@ -1259,6 +1278,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
Expand Down
3 changes: 2 additions & 1 deletion docker/phraseanet/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ set -e

envsubst < "docker/phraseanet/php.ini.sample" > /usr/local/etc/php/php.ini
envsubst < "docker/phraseanet/php-fpm.conf.sample" > /usr/local/etc/php-fpm.conf
cat docker/phraseanet/root/usr/local/etc/php-fpm.d/zz-docker.conf | sed "s/\$REQUEST_TERMINATE_TIMEOUT/$REQUEST_TERMINATE_TIMEOUT/g" > /usr/local/etc/php-fpm.d/zz-docker.conf
envsubst < "docker/phraseanet/root/usr/local/etc/php-fpm.d/zz-docker.conf" > /usr/local/etc/php-fpm.d/zz-docker.conf
# cat docker/phraseanet/root/usr/local/etc/php-fpm.d/zz-docker.conf | sed "s/\$REQUEST_TERMINATE_TIMEOUT/$REQUEST_TERMINATE_TIMEOUT/g" > /usr/local/etc/php-fpm.d/zz-docker.conf

if [ ${XDEBUG_ENABLED} == "1" ]; then
echo "XDEBUG is enabled. YOU MAY KEEP THIS FEATURE DISABLED IN PRODUCTION."
Expand Down
2 changes: 1 addition & 1 deletion docker/phraseanet/php.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ max_input_vars = $MAX_INPUT_VARS

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 2048M
memory_limit = $FPM_MEMORY_LIMIT

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
Expand Down
Loading