Skip to content

8.4 wrong fpmstatus output #16932

Closed
Closed

Description

@PLTytus

Description

fpmstatus seems to return wrong values, sample

pool:                 www
process manager:      dynamic
start time:           25/Nov/2024:13:00:38 +0000
start since:          5057
accepted conn:        1
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       0 
active processes:     1
total processes:      1
max active processes: 11
max children reached: 0
slow requests:        0
memory peak:          81326080

accepted conn not incresing, even decreasing, e.g. shows 3 after refreshing it shows 1 again
idle processes, active processes, idle processes: in this example there 15 running fpm processes in total

PHP Version

8.4.1

Operating System

No response

Activity

  1. devnexen commented on Nov 25, 2024

    @devnexen
    Member

    We might need a bit more to understand if the issue is relevant, i.e. configuration, how the logs look ...

  2. PLTytus commented on Nov 25, 2024

    @PLTytus
    Author

    This is in /usr/local/etc/php-fpm.d/www.conf on php:8.4.1-fpm-alpine image

    [www]
    user = www-data
    group = www-data
    
    pm = dynamic
    pm.max_children = 200
    pm.start_servers = 10
    pm.min_spare_servers = 10
    pm.max_spare_servers = 20
    pm.max_requests = 200
    
    pm.status_listen = 127.0.0.1:9001
    pm.status_path = /fpmstatus
    

    No errors in logs.

    It kind of behaves like processes are overriding current stats: https://github.com/user-attachments/assets/61aab54b-2d25-45c7-b0d7-7562b8aaef2b

    There is no such issue on PHP 8.3

  3. lucasnetau commented on Nov 26, 2024

    @lucasnetau
    Contributor

    Possibly this PR #14153

    fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);

    This is calling FPM_SCOREBOARD_ACTION_SET at the end of the request with all stats set to 0, the unmodified stats should be set as -1

    so either don't set the values

    --- fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
    +++ fpm_scoreboard_update_commit(-1, -1, -1, -1, -1, -1, -1, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);

    or INC vs SET

    --- fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
    +++ fpm_scoreboard_update_commit(0, 0, 0, 0, 0, 0, 0, proc->memory, FPM_SCOREBOARD_ACTION_INC, NULL);
  4. PLTytus commented on Nov 26, 2024

    @PLTytus
    Author

    Looking at fpm_scoreboard_update_commit definition, both @lucasnetau suggested solutions should resolve the issue.

    void fpm_scoreboard_update_commit(
    int idle, int active, int lq, int lq_len, int requests, int max_children_reached,
    int slow_rq, size_t memory_peak, int action, struct fpm_scoreboard_s *scoreboard) /* {{{ */
    {
    scoreboard = fpm_scoreboard_get_for_update(scoreboard);
    if (!scoreboard) {
    return;
    }
    if (action == FPM_SCOREBOARD_ACTION_SET) {
    if (idle >= 0) {
    scoreboard->idle = idle;
    }
    if (active >= 0) {
    scoreboard->active = active;
    }
    if (lq >= 0) {
    scoreboard->lq = lq;
    }
    if (lq_len >= 0) {
    scoreboard->lq_len = lq_len;
    }
    #if HAVE_FPM_LQ /* prevent unnecessary test */
    if (scoreboard->lq > scoreboard->lq_max) {
    scoreboard->lq_max = scoreboard->lq;
    }
    #endif
    if (requests >= 0) {
    scoreboard->requests = requests;
    }
    if (max_children_reached >= 0) {
    scoreboard->max_children_reached = max_children_reached;
    }
    if (slow_rq > 0) {
    scoreboard->slow_rq = slow_rq;
    }
    } else {
    if (scoreboard->idle + idle > 0) {
    scoreboard->idle += idle;
    } else {
    scoreboard->idle = 0;
    }
    if (scoreboard->active + active > 0) {
    scoreboard->active += active;
    } else {
    scoreboard->active = 0;
    }
    if (scoreboard->requests + requests > 0) {
    scoreboard->requests += requests;
    } else {
    scoreboard->requests = 0;
    }
    if (scoreboard->max_children_reached + max_children_reached > 0) {
    scoreboard->max_children_reached += max_children_reached;
    } else {
    scoreboard->max_children_reached = 0;
    }
    if (scoreboard->slow_rq + slow_rq > 0) {
    scoreboard->slow_rq += slow_rq;
    } else {
    scoreboard->slow_rq = 0;
    }
    }
    if (scoreboard->active > scoreboard->active_max) {
    scoreboard->active_max = scoreboard->active;
    }
    if (scoreboard->memory_peak < memory_peak) {
    scoreboard->memory_peak = memory_peak;
    }
    fpm_unlock(scoreboard->lock);
    }

  5. added a commit that references this issue on Nov 26, 2024
    ec4683c
  6. added a commit that references this issue on Nov 27, 2024
    b68ef83
  7. added 2 commits that reference this issue on Nov 28, 2024
    d165670
    e699753
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions