Skip to content

fix: make the PHP memory limit configurable via _APP_MEMORY_LIMIT - #14454

Merged
HarshMN2345 merged 1 commit into
appwrite:fix-configurable-memory-limitfrom
ItsRoy69:fix-14437-configurable-php-memory-limit
Oct 15, 2026
Merged

HarshMN2345 merged 1 commit into
appwrite:fix-configurable-memory-limitfrom
ItsRoy69:fix-14437-configurable-php-memory-limit

Conversation

@ItsRoy69

Copy link
Copy Markdown
Contributor

What does this PR do?

app/init.php set ini_set('memory_limit', '512M') unconditionally on every process. Because a runtime ini_set() always wins over php.ini and php -d, operators could not raise the limit, and Realtime (which holds every WebSocket
connection in memory) was capped at 512M regardless of host RAM.

Changes:

  • app/init.php: ini_set('memory_limit', System::getEnv('_APP_MEMORY_LIMIT', '512M'))
  • app/config/variables.php: define _APP_MEMORY_LIMIT (default 512M, introduction 2.4.0)
  • docker-compose.yml: forward _APP_MEMORY_LIMIT in all PHP services
  • .env: add the default

Test Plan

  • RED/GREEN on the real app/init.php: HEAD with _APP_MEMORY_LIMIT=2G yields memory_limit=512M (bug reproduced); patched yields 2G; unset yields 512M -1 yields -1.
  • docker compose --profile separate config: all 26 Appwrite PHP services resolve _APP_MEMORY_LIMIT=512M; exporting _APP_MEMORY_LIMIT=2G propagates to appwrite and appwrite-realtime.
  • bin/release guard (compose vars vs variables.php, introduction == APP_VERSION_STABLE): PASS.
  • vendor/bin/pint on the changed files: pass. PHPStan on the changed files: no errors.
  • phpunit tests/unit/General config tests and tests/unit/Docker (25/25, incl. Compose\GeneratorTest parsing the root compose): pass.
  • Not run: the ~3,000-connection Realtime OOM storm (needs the built image + a k6 run).

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@ghost

ghost commented Oct 13, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The bootstrap uses the configured value with the existing default, and the root Compose services propagate it consistently.

This change adds _APP_MEMORY_LIMIT with a 512M default and uses it to set PHP's memory limit during bootstrap. The variable is also added to the root Compose PHP services so operators can configure it across the stack.

Verdict New comments Fixed Still open
💬 Commented 0 0 0

Note

@ItsRoy69 does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

📂 Walkthrough · 4
File Change
.env Adds the default _APP_MEMORY_LIMIT=512M setting.
app/config/variables.php Documents _APP_MEMORY_LIMIT as a configurable system variable introduced in 2.4.0.
app/init.php Reads _APP_MEMORY_LIMIT during bootstrap, falling back to 512M.
docker-compose.yml Forwards _APP_MEMORY_LIMIT to the PHP services in the root Compose stack.

Reviewed 000bf13 · 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

@HarshMN2345
HarshMN2345 changed the base branch from main to fix-configurable-memory-limit October 15, 2026 07:23
@HarshMN2345
HarshMN2345 merged commit 56c9bef into appwrite:fix-configurable-memory-limit Oct 15, 2026
1 check passed
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