Repository navigation
Open
Labels
product / storageFixes and upgrades for the Appwrite Storage.
Description
👟 Reproduction steps
- Create a new bucket in an empty project
- Select create file
- Attempt to upload a file that is over 500MB (750MB-1GB seems to trigger consistently, sometimes ~500MB goes through)
- NOTE: Sometimes the first upload will go through but further attempts fail, even after restart of the server
- I have also attempted this with local and S3 storage with similar results in both cases
- Attempted to upload files of size 578.9MB and 1.3GB for testing
👍 Expected behavior
File uploads successfully
👎 Actual Behavior
File uploads fails with the following error in the appwrite pod if using S3 storage method:
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 5242880 bytes) in /usr/src/code/vendor/utopia-php/storage/src/Storage/Device/S3.php on line 228
[2026-06-22 05:14:27 *18.9] ERROR php_swoole_server_rshutdown() (ERRNO 503): Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 5242880 bytes) in /usr/src/code/vendor/utopia-php/storage/src/Storage/Device/S3.php on line 228
[2026-06-22 05:14:27 $7.0] WARNING Worker::report_error(): worker(pid=18, id=9) abnormal exit, status=255, signal=0
The same error occurs for local storage method but in /usr/src/code/vendor/utopia-php/storage/src/Storage/Device/Local.php
🎲 Appwrite version
Different version (specify in environment)
💻 Operating system
Linux
🧱 Your Environment
- Windows Desktop Dev Environment
- Appwrite 1.9.0 running through Docker Desktop using WSL
- 64GB or ram with at least 32GB available during tests
- Attempted with forced allocation of 16GB through deployment section
- Digital Ocean Appwrite Marketplace Server 1
- Appwrite 1.9.0 running through docker
- Basic Shared CPU instance with 2vCPU and 4GB of ram
- Free ram was between 700-450MB during uploads
- Digital Ocean Appwrite Marketplace Server 2
- Appwrite 1.9.0 running through docker
- Basic Shared CPU instance with 8vCPU and 16GB of ram
- Free ram stayed above 12GB during uploads
- All environments used the same .env with only the domain changed
- GCP Storage was used for testing the S3 storage method
👀 Have you spent some time to check if this issue has been raised before?
- I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct
Metadata
Metadata
Assignees
Labels
product / storageFixes and upgrades for the Appwrite Storage.
Activity
gouthamx67 commentedon Jun 23, 2026
Please review #12660 and advise on any necessary changes.
JoshiJoshiJoshi commentedon Oct 4, 2026
We hit the same fatals on 2.3.0, and in our tests the file size isn't the trigger: worker memory grows with every upload request and isn't freed until PHP's cycle collector runs, so a big file (many chunks) just reaches the 512M limit for sure. Raising the limit (#13162) would only move the point where it happens.
Single client, one connection, sequential uploads to one API node, local storage, measuring the RSS of the worker that serves it every 5 s:
Allowed memory size of 536870912 bytes exhaustedandworker abnormal exit, status=255; the next worker does the samegc_collect_cycles()after each request (test patch below)So the memory is held by reference cycles that only get collected once PHP's GC root buffer fills up (10,000 roots); with multi-MB request bodies the 512M limit comes first. We didn't find out which cycle holds the data.
When a worker dies, every request it's handling at that moment gets no response at all, uploads or not. The per-file upload lock (
storage:file:…, TTL 600 s) of a dead request isn't released either, so retrying the same chunk waits for that lock and the whole file is lost (up to 120 s, then429 File upload is busy).Under load (5 parallel uploaders per API node, two nodes, 19 MB files, 20 s client timeout per chunk, 60 s per run), unchanged → test patch → unchanged:
gc_collect_cycles()Test patch (appended to
app/controllers/shared/api.php):Running the collector after every request has its own cost; finding and breaking the cycle (or only collecting after requests with large bodies) would be the cleaner fix, but this shows that the limit isn't reached by live data.