php / php/php-src

Support fastcgi parameter in FPM for status page to display request meta data

Open
#8,880 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature SAPI: fpm
Dominant language
C
Stars
40.4k
Forks
8.2k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

The full FPM status page has very little request data to pinpoint actual running requests and see what's running to get some indication of pool health issues.

It starts with the request uri that actually just shows the request from php, but not the original request - i.e. with a typical front controller pattern it's just something like /front.php. There is already a bug report for that: https://bugs.php.net/bug.php?id=72319 , but I'd suggest that it could stay the same if the real request uri could be added as meta data.

In addition to data a fastcgi param could also be used for different meta data like a client up, nginx request id, etc. It's content and meaning would be in total control of the one using it. FPM itself wouldn't need to do more than showing it in the full status page.

A concrete usage would look like this in a nginx config (param name just for presentation purpose):
fastcgi_param FPM_STATUS_REQUEST_METADATA "$remote_addr $request_id $request_uri";
which would result in an output like that:

[...]
************************
pid:                  1234
state:                Running
start time:           27/Jun/2022:00:00:00 +0000
start since:          0
requests:             1
request duration:     10
request method:       GET
request URI:          /front.php
content length:       100
user:                 -
script:               /httpdocs/front.php
last request cpu:     0.00
last request memory:  0
request metadata: 127.0.0.1 A1B2D3E4F5 /hello/world
************************
[...]

Note: Of course a workaround is sending this as get parameters, but that's not pretty and can break scripts assuming a specific format of the query string or not seeing unknown get parameters.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how FPM parses FastCGI parameters and assembles the full status page output. Use the requested nginx fastcgi_param example and the sample status output as the behavioral target. Done means accepted request metadata is displayed for the relevant running request without changing existing request fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, nginx, php
Domain
backend, observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.