Discover Centmin Mod today
Register Now

PHP-FPM Tweaking configuration

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Jon Snow, Apr 8, 2020.

  1. Jon Snow

    Jon Snow Active Member

    663
    129
    43
    Jun 30, 2017
    Ratings:
    +190
    Local Time:
    4:27 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    Code (Text):
    [07-Apr-2020 20:44:59] WARNING: [pool www] server reached max_children setting (8), consider raising it


    Where can I tweak this where it wouldn't be overwritten with an upgrade?

     
  2. steph40

    steph40 Member

    80
    15
    8
    Jan 28, 2019
    Ratings:
    +32
    Local Time:
    3:27 AM
    1.1.5
    mariadb 10
    I would just add a custom php.ini in /etc/centminmod/php.d
    mine is called b_customphp.ini in that folder. It won't be rewriten.

     
  3. Jon Snow

    Jon Snow Active Member

    663
    129
    43
    Jun 30, 2017
    Ratings:
    +190
    Local Time:
    4:27 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    I see a file named a_customphp.ini which I believe is default? Would that work?

    I don't see any value for max_children, unfortunately.
     
  4. eva2000

    eva2000 Administrator Staff Member

    49,347
    11,308
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,591
    Local Time:
    5:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    See sticky thread at PHP-FPM - How to troubleshoot & optimize PHP-FPM server? with links that reference to all relevant tools and config files to edit

    including links to PHP-FPM - WARNING: [pool www] server reached max_children setting (50), consider raising it

    Also official site has links to all config files overview for entire Centmin Mod server Centmin Mod Configuration Files - CentminMod.com LEMP Nginx web stack for CentOS. Under PHP-FPM section
     
  5. eva2000

    eva2000 Administrator Staff Member

    49,347
    11,308
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,591
    Local Time:
    5:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    that is for php.ini settings but not for php-fpm configuration settings which uses different file as outlined at Centmin Mod Configuration Files - CentminMod.com LEMP Nginx web stack for CentOS

    official site has links to all config files overview for entire Centmin Mod server Centmin Mod Configuration Files - CentminMod.com LEMP Nginx web stack for CentOS. Under PHP-FPM section
     
  6. Jon Snow

    Jon Snow Active Member

    663
    129
    43
    Jun 30, 2017
    Ratings:
    +190
    Local Time:
    4:27 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    @eva2000 That's what I used last time but it was rolled back to 8 at some point. I'm even seeing the increased value in php-fpm.conf-oldversion_numbers-here but 8 is in the current file.
     
  7. eva2000

    eva2000 Administrator Staff Member

    49,347
    11,308
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,591
    Local Time:
    5:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    when you upgrade php via centmin.sh menu option 5, it will prompt if you want to overwrite custom php-fpm.conf file so if you answered yes, then it will. If you don't want to overwrite answer no. You can also disable the prompt to overwrite if you always answer no anyway via adding to your persistent config file /etc/centminmod/custom_config.inc the setting
    Code (Text):
    PHP_OVERWRITECONF='n'
     
  8. Jon Snow

    Jon Snow Active Member

    663
    129
    43
    Jun 30, 2017
    Ratings:
    +190
    Local Time:
    4:27 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    I must have selected yes by mistake in the past. Thanks!

    Should I be worried about this:

    /var/log/nginx/localhost.error.log
    Code (Text):
    2020/04/07 08:54:02 [error] numbers#numbers: *numbers "/usr/local/nginx/html/administrator/index.php" is not found (2: No such file or directory), client: IP, server: hostname, request: "GET /administrator/ HTTP/1.1", host: "server-IP"


    And is there anything I can do to speed up nprestart when used?
     
  9. eva2000

    eva2000 Administrator Staff Member

    49,347
    11,308
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,591
    Local Time:
    5:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    404 not found errors are normal if someone/bot/crawler scans or visitors paths not found on your server. If you use Cloudflare you custom what 404 queried paths can be blocked at Cloudflare Firewall level. I do this on forum for any wordpress related paths that crawlers try to scan/poke at on the forums as there should be no wordpress paths on my forums.
    speed can be relative and usually related to php-fpm service part - more php-fpm children, then potentially longer to restart especially if php-fpm children are actively doing work.
     
  10. Jon Snow

    Jon Snow Active Member

    663
    129
    43
    Jun 30, 2017
    Ratings:
    +190
    Local Time:
    4:27 AM
    Nginx 1.13.9
    MariaDB 10.1.31
    @eva2000 Also, what are the cons of setting values too high?
     
  11. eva2000

    eva2000 Administrator Staff Member

    49,347
    11,308
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,591
    Local Time:
    5:27 PM
    Nginx 1.21.x
    MariaDB 10.x
    discussed at PHP-FPM - WARNING: [pool www] server reached max_children setting (50), consider raising it too

    basically you need to keep an optimal pm.max_children to cpu thread ratio based on your monitored usage profiles for your web apps. In other words if you don't have enough cpu threads available, then raising pm.max_children too high will slow php response times and increase cpu usage

    example excerpt output from Centmin Mod's cminfo phpstats output for 48 cpu thread based server
    Code (Text):
    lscpu
    Architecture:          x86_64
    CPU op-mode(s):        32-bit, 64-bit
    Byte Order:            Little Endian
    CPU(s):                48
    On-line CPU(s) list:   0-47
    Thread(s) per core:    2
    Core(s) per socket:    12
    Socket(s):             2
    NUMA node(s):          2
    Vendor ID:             GenuineIntel
    CPU family:            6
    Model:                 85
    Model name:            Intel(R) Xeon(R) Silver 4116 CPU @ 2.10GHz
    Stepping:              4
    CPU MHz:               2100.000
    CPU max MHz:           3000.0000
    CPU min MHz:           800.0000
    BogoMIPS:              4200.00
    Virtualization:        VT-x
    L1d cache:             32K
    L1i cache:             32K
    L2 cache:              1024K
    L3 cache:              16896K
    NUMA node0 CPU(s):     0-11,24-35
    NUMA node1 CPU(s):     12-23,36-47
    Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 invpcid_single intel_ppin intel_pt ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke md_clear spec_ctrl intel_stibp flush_l1d
    

    actual max php children to cpu ratio = 160:48 = 3.33:1
    Code (Text):
    cminfo phpstats
    
    ------------------------------------------------------------------
    Total PHP-FPM Master Processes: 1
    PHP-FPM Pool Names:
    www
    ------------------------------------------------------------------
     40179 php-fpm: master /usr/local/etc/php-fpm.conf
    ------------------------------------------------------------------
    Current Free Memory (KB): 175901204
    PHP-FPM Available Memory (KB): 187726924
    Estimated Max PHP Children: 2539.91
    Estimated Max PHP Children To CPU Thread Ratio: 52.9149
    PHP-FPM Total Children: 160 from 1 PHP-FPM master(s)
    PHP-FPM Total Used Memory (KB): swap:0 uss:8776660 pss:8795459 rss:11825720
    PHP-FPM Average Per Child (KB): swap:0 uss:54854.1 pss:54971.6 rss:73910.8
    uss = user set size
    pss = process set size
    rss = resident set size
    
    Processes active: 4, idle: 156, Requests: 624291, slow: 0, Traffic: 39req/sec
    pool:                 www
    process manager:      static
    start time:           08/Apr/2020:00:02:39 +0000
    start since:          15659
    accepted conn:        624574
    listen queue:         0
    max listen queue:     1
    listen queue len:     1024
    idle processes:       154
    active processes:     6
    total processes:      160
    max active processes: 72
    max children reached: 0
    slow requests:        0