Php-fpm configuration: encountered and error

Tracy Perry

Well-known member
I just try this and got an error:
Code:
Starting php-fpm [04-Aug-2014 04:54:09] ERROR: [/usr/local/etc/php-fpm.conf:65] unknown entry 'log_level'
[04-Aug-2014 04:54:09] ERROR: failed to load configuration file '/usr/local/etc/php-fpm.conf'
[04-Aug-2014 04:54:09] ERROR: FPM initialization failed
failed
This is what mine is set at in php-fpm.conf (on Debian)
Code:
; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = warning
works fine.
 

eva2000

Well-known member
I just try this and got an error:
Code:
Starting php-fpm [04-Aug-2014 04:54:09] ERROR: [/usr/local/etc/php-fpm.conf:65] unknown entry 'log_level'
[04-Aug-2014 04:54:09] ERROR: failed to load configuration file '/usr/local/etc/php-fpm.conf'
[04-Aug-2014 04:54:09] ERROR: FPM initialization failed
failed
add to top of the file not bottom of file :)
 

rdn

Well-known member
My current config:
Code:
pm = dynamic
pm.max_children = 16
pm.start_servers = 6
pm.min_spare_servers = 4
pm.max_spare_servers = 8
pm.max_requests = 500
 

Floren

Well-known member
pm.max_children = 16
The highest value I ever used on any setup was 32, regardless of the additional number of processors. In real life the calculation is a lot more complex. Basically you need to make sure the total PHP allocated memory does not go higher than the total free server memory, which is pretty complex to determine accurately. In other words, if you set the PHP memory to 256MB and max_children to 32, then you should have at least 256MB x 32 (8GB) of free RAM to allocate it only for PHP. Most web node setups I do have 8 processors and 32GB of RAM so setting the max_children to 32 is not an issue. That explains the logic behind the number of procs x 4. Even if I have 32GB of RAM on a 4 processors node, I will still set the max_children to 16 (not 32), following the number of procs x 4 rule. On my Siege benchmarks I noticed a correlation to this number.

There is another important number to keep in mind: pm.max_spare_servers cannot be greater than pm.max_children, this should help you to calculate the rest of your numbers accordingly.
pm.max_requests = 500
It is still very high, lower it to 100 or less. I use 100 for sites with 30,000+ online users.
 
Last edited:

rdn

Well-known member
Thanks a lot for the lessons @Floren :)
Learn a lot from you guys. (y)

Adjusted Config:
Code:
pm = dynamic
pm.max_children = 16
pm.start_servers = 6
pm.min_spare_servers = 4
pm.max_spare_servers = 10
pm.max_requests = 100
 
Last edited:

Floren

Well-known member
@RoldanLT, you are welcome. You can test easy those numbers and see how your server reacts if it gets hit by a large number of users online. It will help you tune properly the PHP numbers.
Code:
# yum --enablerepo=axivo install siege
# siege -u https://www.phcorner.net/ -c 2000 -d 30 -t 1M
Lifting the server siege...      done.

Transactions:               6604 hits
Availability:             100.00 %
Elapsed time:              59.73 secs
Data transferred:         180.24 MB
Response time:               1.18 secs
Transaction rate:         110.56 trans/sec
Throughput:               3.02 MB/sec
Concurrency:             130.48
Successful transactions:        6604
Failed transactions:              0
Longest transaction:           7.43
Shortest transaction:           0.04

# siege -u https://mattwservices.co.uk/ -c 2000 -d 30 -t 1M
Lifting the server siege...      done.

Transactions:               6951 hits
Availability:             100.00 %
Elapsed time:              59.09 secs
Data transferred:          82.08 MB
Response time:               0.37 secs
Transaction rate:         117.63 trans/sec
Throughput:               1.39 MB/sec
Concurrency:              43.98
Successful transactions:        6951
Failed transactions:              0
Longest transaction:           5.49
Shortest transaction:           0.33

# siege -u https://www.axivo.com/forums/ -c 2000 -d 30 -t 1M
Lifting the server siege...      done.

Transactions:               7030 hits
Availability:             100.00 %
Elapsed time:              59.12 secs
Data transferred:          60.82 MB
Response time:               0.28 secs
Transaction rate:         118.91 trans/sec
Throughput:               1.03 MB/sec
Concurrency:              32.77
Successful transactions:        7030
Failed transactions:              0
Longest transaction:           1.28
Shortest transaction:           0.02
I gently DDoS'ed your forums and @MattW's, just now... with 2,000 users. :D
You should enable a protection so only a number of requests can be performed from a specific IP. I just wanted to show you the differences, so you see there is still room for improvement. :)

Of course, I had no cache enabled on my side...
 
Last edited:

Floren

Well-known member
@MattW, you were not spared of the test... Let's test @eva2000's Centminmod:
Code:
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
The server file descriptors are not sufficient, dang. You guys really need to protect your servers from multiple request attacks.
 

rdn

Well-known member
I gently DDoS'ed your forums, just now. :D
Hehe :D
With your output, our website vary with a lot of things.
  • I got 43 addons NOT counting Template Modification.
  • 3 Styles.
  • Hundreds of customized phrases
  • 600+ user online right now
  • Almost 200 Forum Nodes
 

MattW

Well-known member
I also have tenants dedos addon installed, along with xfrocks bdcache. Guests hitting the home page get a HTML version of the page served from memcached.
 

Floren

Well-known member
With your output, our website vary with a lot of things.
Nothing to do with your add-ons and online users, see the siege manual related to the settings I used. :)
Is all about the server hardware mainly... mines runs on this tiny processor with 8GB of RAM:
Code:
# nproc
4

# free -m
             total       used       free     shared    buffers     cached
Mem:          7770       1209       6561          0         22        286
-/+ buffers/cache:        899       6870
Swap:         8191          0       8191

# dmidecode -t processor
# dmidecode 2.12
SMBIOS 2.7 present.

Handle 0x0004, DMI type 4, 42 bytes
Processor Information
    Socket Designation: LGA1155 CPU 1
    Type: Central Processor
    Family: Core i5
    Manufacturer: Intel(R) Corp.
    ID: A9 06 03 00 FF FB EB BF
    Signature: Type 0, Family 6, Model 58, Stepping 9
    Flags:
        FPU (Floating-point unit on-chip)
        VME (Virtual mode extension)
        DE (Debugging extension)
        PSE (Page size extension)
        TSC (Time stamp counter)
        MSR (Model specific registers)
        PAE (Physical address extension)
        MCE (Machine check exception)
        CX8 (CMPXCHG8 instruction supported)
        APIC (On-chip APIC hardware supported)
        SEP (Fast system call)
        MTRR (Memory type range registers)
        PGE (Page global enable)
        MCA (Machine check architecture)
        CMOV (Conditional move instruction supported)
        PAT (Page attribute table)
        PSE-36 (36-bit page size extension)
        CLFSH (CLFLUSH instruction supported)
        DS (Debug store)
        ACPI (ACPI supported)
        MMX (MMX technology supported)
        FXSR (FXSAVE and FXSTOR instructions supported)
        SSE (Streaming SIMD extensions)
        SSE2 (Streaming SIMD extensions 2)
        SS (Self-snoop)
        HTT (Multi-threading)
        TM (Thermal monitor supported)
        PBE (Pending break enabled)
    Version: Intel(R) Core(TM) i5-3570S CPU @ 3.10GHz
    Voltage: 1.7 V
    External Clock: 25 MHz
    Max Speed: 4000 MHz
    Current Speed: 3100 MHz
    Status: Populated, Enabled
    Upgrade: Socket BGA1155
    L1 Cache Handle: 0x0005
    L2 Cache Handle: 0x0006
    L3 Cache Handle: 0x0007
    Serial Number: To Be Filled By O.E.M.
    Asset Tag: To Be Filled By O.E.M.
    Part Number: To Be Filled By O.E.M.
    Core Count: 4
    Core Enabled: 1
    Characteristics:
        64-bit capable
Here it is another test with lower numbers, just to demonstrate that increasing the number of servers does not really help:
Code:
# grep ^pm /etc/php-fpm.d/www.conf
pm = dynamic
pm.max_children = 8
pm.start_servers = 6
pm.min_spare_servers = 4
pm.max_spare_servers = 8
pm.max_requests = 100

# siege -u https://www.axivo.com/forums/ -c 2000 -d 30 -t 1M
Lifting the server siege...      done.

Transactions:               7126 hits
Availability:             100.00 %
Elapsed time:              59.16 secs
Data transferred:          61.61 MB
Response time:               0.32 secs
Transaction rate:         120.45 trans/sec
Throughput:               1.04 MB/sec
Concurrency:              38.46
Successful transactions:        7126
Failed transactions:              0
Longest transaction:           1.57
Shortest transaction:           0.02

# top -M
top - 02:53:24 up  1:05,  2 users,  load average: 2.96, 0.86, 0.47
Tasks: 161 total,   1 running, 160 sleeping,   0 stopped,   0 zombie
Cpu(s): 57.4%us,  6.8%sy,  0.0%ni, 34.4%id,  0.0%wa,  0.0%hi,  1.4%si,  0.0%st
Mem:  7770.230M total, 1225.762M used, 6544.469M free,   22.562M buffers
Swap: 8191.992M total,    0.000k used, 8191.992M free,  286.328M cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND               
31504 php-fpm   20   0  995m  16m 8792 S 23.3  0.2   0:01.12 php-fpm               
31505 php-fpm   20   0  995m  16m 8796 S 23.3  0.2   0:00.88 php-fpm               
1742 mysql     20   0 1786m 305m 9104 S 22.9  3.9   2:05.98 mysqld                 
31503 php-fpm   20   0  995m  16m 8804 S 22.9  0.2   0:01.48 php-fpm               
31506 php-fpm   20   0  995m  16m 8792 S 21.9  0.2   0:00.66 php-fpm               
31507 php-fpm   20   0  995m  16m 8796 S 21.0  0.2   0:00.63 php-fpm               
31508 php-fpm   20   0  995m  16m 8796 S 13.3  0.2   0:00.40 php-fpm               
31509 php-fpm   20   0  995m  16m 8796 S 12.3  0.2   0:00.37 php-fpm               
31510 php-fpm   20   0  995m  16m 8792 S 11.0  0.2   0:00.33 php-fpm               
29397 nginx     20   0  174m  25m 2032 S  8.6  0.3   0:04.93 nginx                 
29398 nginx     20   0  174m  24m 2024 S  8.6  0.3   0:04.98 nginx                 
1403 memcache  20   0  375m  24m  600 S  5.3  0.3   0:24.93 memcached             
29399 nginx     20   0  174m  25m 2024 S  4.3  0.3   0:04.46 nginx
I'm actually going to leave those number ON, they return better results...
 
Last edited:
  • Like
Reactions: rdn

rdn

Well-known member
along with xfrocks bdcache. Guests hitting the home page get a HTML version of the page served from memcached.
But not all pages are cache with BD Cache addon.
If someone can write up a working config for fastcgi_cache on XenForo forum, that would be awesome :)


Of course you can, God gave you hands to type and search the Nginx documentation. :)
But, On my Admin page, most IP has 20+ user's.
I'm afraid I can block some valid user because of that.
 

Floren

Well-known member
@RoldanLT, @MattW, I'm not talking about bots etc. I'm talking about forcing any legitimate user not to abuse your server like I did minutes ago. Try to siege AXIVO, you will what you get as result. I certainly did NOT blocked your IP's, heh.
 
  • Like
Reactions: rdn

MattW

Well-known member
@RoldanLT, @MattW, I'm not talking about bots etc. I'm talking about forcing any legitimate user not to abuse your server like I did minutes ago. Try to siege AXIVO, you will what you get as result. I certainly did NOT blocked your IP's, heh.
Will have a look when my daughter goes for her morning nap
 

eva2000

Well-known member
@MattW, you were not spared of the test... Let's test @eva2000's Centminmod:
Code:
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
[error] descriptor table full sock.c:119: Too many open files
The server file descriptors are not sufficient, dang. You guys really need to protect your servers from multiple request attacks.
you testing Matt's server ? I believe that is on your Axivo rpms now ??? Centminmod only provides the LEMP stack and basic config, configuring individual web apps (XF) is up to end users :)
 
Top