Welcome to Centmin Mod Community
Become a Member

PHP-FPM PHP-FPM tuning help!

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by KinderOvO, Nov 12, 2019.

  1. KinderOvO

    KinderOvO Member

    91
    1
    8
    Jan 13, 2015
    Ratings:
    +1
    Local Time:
    12:04 AM
    1.4
    10
    Hi, I have a 3900x / 64GB memory / 1TB NVME RAID 1 server.

    I'm having php-fpm slowdown issues currently I use the following configs.

    pm = ondemand
    pm.max_children = 30
    pm.start_servers = 8
    pm.min_spare_servers = 4
    pm.max_spare_servers = 12
    pm.max_requests = 5000

    and nginx worker_processes auto i use auto like this

    user nginx nginx;
    worker_processes auto;
    worker_cpu_affinity auto;
    worker_priority -10;

    events {
    worker_connections 100000;
    accept_mutex off;
    accept_mutex_delay 200ms;
    use epoll;
    #multi_accept on;
    }


    how could i better, is there much difference between ondemand and dynamic?
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,502
    10,164
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,732
    Local Time:
    12:04 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
  3. rdan

    rdan Well-Known Member

    4,942
    1,180
    113
    May 25, 2014
    Ratings:
    +1,789
    Local Time:
    10:04 PM
    Mainline
    10.2
  4. Manoj malviya

    Manoj malviya New Member

    19
    1
    3
    Dec 21, 2019
    Ratings:
    +1
    Local Time:
    7:34 PM
    1.17.6
    10.3.20
    i have a dedicated server which have 128 gb of ram and xeon processor with 1gbps bandwidth. I have installed centminmod on my server but the issue I am facing is that when my traffic raise to 3000 realtime the server stop responding.

    What I am looking for what will be the configuration of php-fpm so it can handle 10000 realtime users
    My configuration is this

    global]
    ; Log level
    ; Possible Values: alert, error, warning, notice, debug
    ; Default Value: notice
    log_level = warning
    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 = 65535

    ;listen = /tmp/php5-fpm.sock
    listen.owner = nginx
    listen.group = nginx
    listen.mode = 0660

    pm = static
    pm.max_children = 3072
    ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
    pm.start_servers = 100
    pm.min_spare_servers = 10000
    pm.max_spare_servers = 15000
    pm.max_requests = 10000

    ; 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
    ; Default Value: 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

    ; catch_workers_output = yes
    php_admin_value[error_log] = /var/log/php-fpm/www-php.error.log
    php_admin_value[disable_functions] = shell_exec.
     
  5. pamamolf

    pamamolf Premium Member Premium Member

    3,811
    369
    83
    May 31, 2014
    Ratings:
    +711
    Local Time:
    5:04 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    You can try something like:

    pm = dynamic
    pm.max_children = 80
    ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
    pm.start_servers = 32
    pm.min_spare_servers = 16
    pm.max_spare_servers = 64
    pm.max_requests = 8000
     
  6. Manoj malviya

    Manoj malviya New Member

    19
    1
    3
    Dec 21, 2019
    Ratings:
    +1
    Local Time:
    7:34 PM
    1.17.6
    10.3.20
    Will this configuration will able to handle 10000 realtime users?
     
  7. pamamolf

    pamamolf Premium Member Premium Member

    3,811
    369
    83
    May 31, 2014
    Ratings:
    +711
    Local Time:
    5:04 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    I think so....
     
  8. Manoj malviya

    Manoj malviya New Member

    19
    1
    3
    Dec 21, 2019
    Ratings:
    +1
    Local Time:
    7:34 PM
    1.17.6
    10.3.20
    just queries how you calculate this configuration will be right for 10000 users.

    If I need to increase it more what will be the things i need to check
     
  9. pamamolf

    pamamolf Premium Member Premium Member

    3,811
    369
    83
    May 31, 2014
    Ratings:
    +711
    Local Time:
    5:04 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    It is my personal estimation for your current server cpu cores+threads+ram...

    There are a lot more factors to just say use that numbers and you will be able to handle 10000 users as it depends for example:

    What each user does and what's the cost of each request for php.
    How well is the server optimized.
    How well is your software optimized

    and a lot more.

    But keep in mind that i am not an expert but you can easily test (if you don't have any other recommendations) my recommendation and if you don't like it just revert the edits and do a simple restart of phpfpm :)