Need an advice for php-fpm optimization

rdn

Well-known member
Server Specs:
CPU: Intel i5 (4 cores / 4 Threads)
Frequency: 3.1GHz (3.8GHz Turbo Boost)
RAM: 8 GB DDR3
CentOS 6.5 Server
Nginx 1.5.7
Php 5.5.7

My current php-fpm.conf:
Code:
pid = /var/run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/www-error.log
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s
include=/usr/local/nginx/conf/phpfpmd/*.conf

[www]
user = nginx
group = nginx

listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
;listen.backlog = -1

pm = ondemand
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 500

; PHP 5.3.9 setting
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
pm.process_idle_timeout = 10s;

rlimit_files = 65536
rlimit_core = 0

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
;request_slowlog_timeout = 0
slowlog = /var/log/php-fpm/www-slow.log

pm.status_path = /phpstatus
ping.path = /phpping
ping.response = pong

; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
security.limit_extensions = .php .php3 .php4 .php5

; catch_workers_output = yes
php_admin_value[error_log] = /var/log/php-fpm/www-php.error.log
 
I didn't really edit a whole lot in the php-fpm conf file when setting up nginx. It seems to work pretty well with most out-of-the-box directives. However, you do have pm = ondemand specified. I've never tried it this way, but in that case, you should only need two directives: pm.max_children and pm.process_idle_timeout
The other directives you have are really only for the pm = dynamic setup, which spawns the child processes and has them stay idle. Ondemand means that the children will be forked when connections are made.
 
  • Like
Reactions: rdn
Top Bottom