Skip to content

docs: expand PHP-FPM tuning section with real guidance#14923

Open
skjnldsv wants to merge 2 commits into
masterfrom
fix/php-fpm-documentation
Open

docs: expand PHP-FPM tuning section with real guidance#14923
skjnldsv wants to merge 2 commits into
masterfrom
fix/php-fpm-documentation

Conversation

@skjnldsv
Copy link
Copy Markdown
Member

@skjnldsv skjnldsv commented May 19, 2026

☑️ Resolves

Summary

The existing "Tune PHP-FPM" section in server_tuning.rst was a two-sentence
stub that linked to an external calculator without explaining anything. PHP-FPM is
the only option for Nginx setups and a frequent source of performance problems
(502s, 504s, sync failures) when misconfigured — yet the docs gave admins nothing
to work with.

This PR replaces the stub with a full section covering:

  • Process manager modes (dynamic / static / ondemand) — behaviour,
    trade-offs, and Nextcloud-specific guidance (ondemand not recommended because
    desktop/mobile clients poll every 30s, causing repeated cold-start latency)
  • Key parameterspm.max_children, pm.start_servers,
    pm.min_spare_servers/pm.max_spare_servers, pm.max_requests,
    pm.process_idle_timeout — with the RAM-based sizing formula and how to
    measure actual worker RSS from a live pool
  • Example dynamic config as a starting point for a 2 GB PHP-RAM server
  • Slow log setup (slowlog + request_slowlog_timeout) for identifying
    bottlenecks
  • Troubleshooting for the four most common FPM-related complaints: 502,
    504, memory growth over time, and cold-start lag
  • Cross-reference to source_installation.rst (php_fpm_tips_label) for pool
    config details (env vars, upload sizes, Unix socket vs TCP) to avoid duplication

Content researched from: PHP manual (install.fpm.configuration), the Medium
article linked in the issue, and existing Nextcloud pool config notes in
source_installation.rst.

🖼️ Screenshots

image image image image image

✅ Checklist

  • I have built the documentation locally and reviewed the output
  • Screenshots are included for visual changes (n/a — text only)
  • I have not moved or renamed pages (or added a redirect if I did)
  • I have run codespell or similar and addressed any spelling issues

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

📖 Documentation Preview

🔍 Open preview →

📄 1 changed documentation page

Last updated: Wed, 20 May 2026 05:13:25 GMT

@skjnldsv

This comment has been minimized.

This comment has been minimized.

@skjnldsv skjnldsv force-pushed the fix/php-fpm-documentation branch from 72b3576 to cc5d93d Compare May 20, 2026 04:20
Replace the two-sentence stub with real content covering:
- pm modes (dynamic/static/ondemand) with trade-offs and Nextcloud
  guidance (ondemand not recommended; sync clients cause repeated
  cold starts)
- Key parameters: pm.max_children, start/min/max spare servers,
  pm.max_requests, pm.process_idle_timeout — with the RAM-based
  sizing formula and how to measure actual worker RSS
- Example dynamic config for 2 GB PHP RAM
- Slow log setup (slowlog + request_slowlog_timeout)
- Troubleshooting section: 502, 504, memory growth, cold-start lag
- Cross-reference to source_installation.rst for pool/env-var detail

Fixes #11591

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@skjnldsv skjnldsv force-pushed the fix/php-fpm-documentation branch from cc5d93d to 5e0c688 Compare May 20, 2026 04:25
@skjnldsv skjnldsv self-assigned this May 20, 2026
The list-table with widths 15/85 caused horizontal overflow in the
rendered HTML. Definition list avoids the issue and is more idiomatic
RST for key-value mode descriptions.

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@skjnldsv skjnldsv force-pushed the fix/php-fpm-documentation branch from ad8ff8a to df99ddc Compare May 20, 2026 05:07
@skjnldsv skjnldsv enabled auto-merge May 20, 2026 05:53
@szaimen szaimen removed their request for review May 20, 2026 08:03

Measure the average RSS of a running pool::

ps --no-headers -o rss -C php-fpm8.3 | awk '{sum+=$1} END {print sum/NR/1024 " MB"}'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command assume some php process are running, right? Maybe we need to specify it. Else, I got the following error: awk: cmd. line:1: fatal: division by zero attempted

directory trees. Use the slow log to identify the bottleneck.

**Memory grows over time**
Workers are leaking memory (Imagick and XML parsers are common sources).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are Imagick and XML parsers really at fault? Do we have some sources for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improving PHP-FPM documentation

3 participants