fix(init): make the PHP memory limit configurable by HarshMN2345 · Pull Request #14522 · appwrite/appwrite · GitHub
Skip to content

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

Open
HarshMN2345 wants to merge 3 commits into
mainfrom
fix-configurable-memory-limit
Open

HarshMN2345 wants to merge 3 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
Signed-off-by: Jyotirmoy Roy <jyotirmoyroy649@gmail.com>
…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.
@tenki-reviewer

tenki-reviewer Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

@hansi-codes

hansi-codes Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

🟢 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.

Reviewed 15c33a7 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@hansi-codes hansi-codes Bot left a comment

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.

🟢 Tier S · Looks good to merge. Summary

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

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

Metric Before After Change
🚀 Requests/sec 206.28 215.82 ⚪ +4.6%
⏱️ Latency P50 81.9 ms 79.74 ms ⚪ -2.6%
⏱️ Latency P95 196.84 ms 187.33 ms ⚪ -4.8%
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.74 187.33 13,680 215.82 -9.52
Account 150.98 301.65 720 11.92 +16.79
TablesDB 77.12 151.3 7,440 119.24 -5
Storage 72.31 159.01 3,600 59.6 -9.54
Functions 114.41 223.7 1,920 32.3 -1.1

Top API waits (after)

API request Max wait (ms)
account.name.update 438.33
functions.create 417.5
functions.variables.update 389.85
storage.buckets.create 355.52
account.prefs.update 349.55

@github-actions

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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