Skip to content

fix(init): make the PHP memory limit configurable - #14522

Merged
HarshMN2345 merged 4 commits into
mainfrom
fix-configurable-memory-limit
Oct 23, 2026
Merged

HarshMN2345 merged 4 commits into
mainfrom
fix-configurable-memory-limit

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

app/init.php hardcoded ini_set('memory_limit', '512M') for every process, overriding php -d and ini files, so a Realtime worker died at 512 MB and dropped every connection on that node.

The limit now reads _APP_MEMORY_LIMIT, still defaulting to 512M. It's forwarded to every PHP service in docker-compose.yml (the three extends services inherit it), defined in variables.php next to _APP_WORKER_PER_CORE with introduction 2.5.1, and added to .env.

Tested: loaded the real app/init.php in appwrite-dev:latest under php -d memory_limit=128M. With _APP_MEMORY_LIMIT unset or empty the limit is 512M; with 2G it's 2G; with -1 it's -1. pint --test passes on both PHP files.

Closes #14437

Related: #14454 (merged into this branch), #13162 (same change, open since August)

ItsRoy69 and others added 3 commits October 13, 2026 22:07
…mory-limit

fix: make the PHP memory limit configurable via _APP_MEMORY_LIMIT
Set its introduction to the next patch, since 2.4.0 has shipped, and
shorten the description.
@luxor-code-review

luxor-code-review Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR introduces a configurable PHP memory limit for the Appwrite server via a new optional _APP_MEMORY_LIMIT environment variable.

Files Change
.env / docker-compose.yml Declares _APP_MEMORY_LIMIT and passes it through to the container services.
app/config/variables.php Adds catalog metadata for _APP_MEMORY_LIMIT as an optional variable with a documented default.
app/init.php Applies the variable at bootstrap via ini_set(memory_limit, ...), falling back to 512M.

Reviewed commit: 15c33a7

@ghost

ghost commented Oct 15, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The configurable value falls back correctly when unset or empty, and the PHP services in Compose receive the setting.

The PHP bootstrap now reads its memory limit from _APP_MEMORY_LIMIT, defaulting to 512M. The Compose configuration forwards the setting to the PHP services, and the environment template and variable catalog document the option.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 4
File Change
.env Adds _APP_MEMORY_LIMIT=512M to the default environment.
app/config/variables.php Registers the memory-limit setting and documents accepted values and defaults.
app/init.php Uses _APP_MEMORY_LIMIT when setting PHP's memory limit.
docker-compose.yml Forwards _APP_MEMORY_LIMIT to the PHP services, including services that extend configured workers.

Merged main (66e93de); no changes to this PR's code since 15c33a7 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix-configurable-memory-limit (after).

Metric Before After Change
🚀 Requests/sec 211 215.5 ⚪ +2.1%
⏱️ Latency P50 79.41 ms 79.57 ms ⚪ +0.2%
⏱️ Latency P95 191.8 ms 192.13 ms ⚪ +0.2%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 79.57 192.13 13,566 215.5 +0.34
Account 156.63 305.05 714 11.97 +33.44
TablesDB 78.17 151.04 7,378 119.54 +10.23
Storage 70.34 171.37 3,570 59.47 -25.62
Functions 112.48 216.63 1,904 32.38 -5.98

Top API waits (after)

API request Max wait (ms)
account.name.update 551.98
functions.create 446.5
tablesdb.rows.create 414.61
functions.variables.update 406.26
account.prefs.update 388.34

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@HarshMN2345
HarshMN2345 merged commit 5f3fc62 into main Oct 23, 2026
68 of 69 checks passed
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…ry-limit

fix(init): make the PHP memory limit configurable

(cherry picked from commit 5f3fc62)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: Hardcoded memory_limit 512M crashes Realtime and drops all clients at ~3,000 connections per container

2 participants