Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

PHP-FPM Configuration 101 (php-fpm.conf, www.conf)

Global Directives (php-fpm.conf)

Define emergency_restart_threshold Value
Purpose: If this number of child processes exit with Segmentation, page fault, and access violation (SIGSEGV or SIGBUS) within the time interval set by emergency_restart_interval then FPM will restart
Default Value: 0 means Off
emergency_restart_threshold = 10

Define emergency_restart_interval Value
Purpose: Interval of time used to determine when a graceful restart will be initiated.  This can be useful to work around accidental corruptions in an accelerator’s shared memory
Default Value: 0
Available Units: s(econds), m(inutes), h(ours), or d(ays)
emergency_restart_interval = 1m

Define process_control_timeout Value
Purpose: Time limit for child processes to wait for a reaction on signals from master
Default Value:
process_control_timeout = 10

You know the Platform, define Events Notification Mechanism for FPM
Purpose: Choosen mechanism used by FPM for events notification
Supported Mechanism(s):

    select     (any POSIX os)
    poll       (any POSIX os)
    epoll      (linux >= 2.5.44)
    kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
    /dev/poll  (Solaris >= 7)
    port       (Solaris >= 10)

events.mechanism = epoll
Pool Directives (default name is www.conf)

Multiple pools of child processes may be started with different listening ports and different management options.  The name of the pool will be used in logs and stats. There is no limitation on the number of pools which FPM can handle. So system limit is the FPM limit.

Define Listen mode, FPM supports Unix Socket and TCP Socket
Purpose: It used to mode connecting mechanism of PHP request from frontend server (like nginx, etc)
Default Value: TCP Socket
listen =

Need more pool for application specific
listen =
listen =

Define Backlog limit
Purpose: The backlog argument defines the maximum length to which the queue of pending connections
Default Value: 128 for Linux / -1 for on FreeBSD and OpenBSD (‘-1′ means unlimited)
listen.backlog = -1

Define Process Manager controll mechanism of Child process
Possible Values: static, dynamic, ondemand
Describing Values: widely used values are static and dynamic

    static  – a fixed number (pm.max_children) of child processes
    dynamic – the number of child processes are set dynamically based on the following directives. With this process management, there will be always at least 1 children
    ondemand – no children are created at startup. Children will be forked when new requests will connect

Configuration: This is a mandatory value
pm = dynamic

Define Process Manager Maximum children limit
Purpose: 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’
Note: Equivalent to the ApacheMaxClients directive with mpm_prefork
Default Value: 5
Configuration: This value is mandatory
pm.max_children = 5

Define support directives for Process Manager definition
Purpose: Child process management configuration for FPM, this configuration directives is applicable, when pm is set to ‘dynamic’
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

Define Maxmium Requests limit for child process
Purpose: The number of requests each child process should execute before respawning (recreation of child process)
Default Value: 0
Configuration: For endless request processing specify ’0′
pm.max_requests = 10000

Define Request Slowlog Time out
Purpose: The timeout for serving a single request after which a PHP backtrace will be dumped to the ‘slowlog’ file.
Default Value: 0
Configuration: A value of ’0s’ means ‘off’
request_slowlog_timeout = 5s

Define Script Slow log
Purpose: Logging slow requests information into slowlog
Default Value: not defined
Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = /var/log/$pool.log.slow

Define Request Terminate Time Limit
Purpose: 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
Default Value: 0
Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
Configuration: A value of ’0′ means ‘off’
request_terminate_timeout = 300s

Define Open File Descripter Limit
Purpose: This directive allows to override a system defined limit for Open File descriptor for PHP-FPM
Default Value: System defined value
Alternate (System defined): soft & hard nofile limit at system level
rlimit_files = 131072

Define Max Core limit
Purpose: A process can set its soft RLIMIT_CORE resource limit to place an upper limit on the size of the core dump file that will be produced if it receives a “core dump” signal
Default Value: System defined value
Possible Values: ‘unlimited’ or an integer greater or equal to 0
rlimit_core = unlimited

Define Whether to catch workers output
Purpose: Redirect worker stdout and stderr into main error log. If not set, stdout and stderr will be redirected to /dev/null according to FastCGI specs
Default Value: no
Consideration: On high loaded environment, this can cause some delay in the page process time (several ms)
catch_workers_output = yes

Pass Environment variables to PHP-FPM process
Purpose: All $VARIABLEs are taken from the current environment.
Default Value: clean env
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
Recommendation for PHP-FPM monitoring


    By default the status page output is formatted as text/plain. Passing either ‘html’, ‘xml’ or ‘json’ in the query string will return the corresponding
    By default the status page only outputs short status. Passing ‘full’ in the query string will also return status for each pool process

For example:

Purpose: The URI to view the FPM status page
Default Value: Not defined
pm.status_path = /status
Just for Handy Use – Putting together

php-fpm.conf  – php-fpm configuration 101
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10
events.mechanism = epoll

asked Sep 20, 2013 in PHP by rajesh
0 votes

Related Hot Questions

Government Jobs Opening