How do I change the defaults for PHP-FPM? Which file(s) are responsible?
Hi,
I am trying to optimise performance of my server to make the websites fast (currently sluggish). I have tweaked my.cnf based on suggestions for my server spec which is:
Mainboard.......: X9DRD-iF
CPU.............: 2 x Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz
Memory..........: DDR3 1333MHz 64GB (5 x 16GB 1333MHz RDIMM)
Disk 1..........: Seagate 20TB HDD SN: ZVT7A9GK
RAID............: No RAID
OS..............: CloudLinux release 8.9.0
Control Panel...: CPanel version 120.0.5
IPs.............: 1 Vlan IP (/30)
Bandwidth.......: 1GBPS Unmetered
I have resource intensive high traffic website with large amount of content. I have made changes to my.cnf as follows
[mysqld]
disable-log-bin=1
default-authentication-plugin=mysql_native_password
performance-schema=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# Memory Settings
innodb_buffer_pool_size=40G
innodb_log_file_size=10G
innodb_log_buffer_size=512M
# InnoDB Settings
innodb_file_per_table=1
innodb_flush_log_at_trx_commit=2
innodb_flush_method=O_DIRECT
innodb_open_files=8192
innodb_io_capacity=2000
innodb_lock_wait_timeout=600
innodb_read_io_threads=64
innodb_write_io_threads=64
innodb_io_capacity_max=4000
# General Settings
max_allowed_packet=256M
open_files_limit=20000
max_connections=1000
thread_cache_size=256
# Cache Settings
table_open_cache=8000
table_definition_cache=8000
# Temporary Table Settings
tmp_table_size=1G
max_heap_table_size=1G
# Buffer Sizes
join_buffer_size=64M
sort_buffer_size=16M
read_buffer_size=8M
read_rnd_buffer_size=16M
# Logging
slow_query_log=1
slow_query_log_file=/var/log/mysql-slow.log
long_query_time=2
# Other Settings
mysqlx=0
# Performance schema
performance_schema=ON
These are the suggestions to improve PHP-FPM, first is to adjust the general php-fpm configuration with the following changes:
[global]
pid = /run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/error.log
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s
daemonize = yes
Secondly, the PHP-FPM pool configuration file
[www]
user = nginx
group = nginx
listen = /run/php-fpm/www.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
; Set the number of PHP-FPM child processes based on your server's resources
pm = dynamic
pm.max_children = 100
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 30
pm.max_requests = 500
; Adjust these settings based on your traffic and available memory
request_terminate_timeout = 30s
request_slowlog_timeout = 5s
slowlog = /var/log/php-fpm/www-slow.log
; Optional: Adjust these settings if you encounter performance issues
rlimit_files = 65536
rlimit_core = unlimited
catch_workers_output = yes
; Logging
access.log = /var/log/php-fpm/www-access.log
And also OpCache:
[opcache]
opcache.enable=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=0
opcache.validate_timestamps=0
Finally to increase php memory limit and max execution.
memory_limit = 512M
max_execution_time = 300
My question is, do these changes look ok for my server specification? And where do I find the PHP-FPM files to make those changes?
Kind regards
Chris
Please sign in to leave a comment.
Comments
1 comment