Skip to content

Uploading files greater then 500MB to storage fails #12643

Open

Description

@JoshLee0915

👟 Reproduction steps

  1. Create a new bucket in an empty project
  2. Select create file
  3. 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?

Activity

  1. added theissue type on Jun 22, 2026
  2. added
    product / domains
    product / functions
    product / sites
    product / storage
    product / vcs
    on Jun 22, 2026
  3. gouthamx67 commented on Jun 23, 2026

    @gouthamx67

    Please review #12660 and advise on any necessary changes.

  4. JoshiJoshiJoshi commented on Oct 4, 2026

    @JoshiJoshiJoshi

    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:

    Upload worker RSS result in 35 s
    19 MB files in 5 MiB chunks 115 → 328 → 543 MB, then Allowed memory size of 536870912 bytes exhausted and worker abnormal exit, status=255; the next worker does the same 36 files, 1 request without a response
    5 MB files, one request each 115 → 356 → 572 MB, then the same 134 files, 1 request without a response
    1 MB files up to 282 MB, then falls back 864 files, OK
    5 MB files with gc_collect_cycles() after each request (test patch below) stable at 160–171 MB 300 files, 0 crashes

    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, then 429 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:

    2.3.0 with gc_collect_cycles() 2.3.0
    unencrypted bucket 5.06 files/s, 22 chunks without response 15.14 files/s, 0 5.20 files/s, 22
    encrypted bucket 4.01 files/s, 20 chunks without response 11.10 files/s, 0 3.59 files/s, 20
    memory fatals in the logs (both nodes) 58 0 60

    Test patch (appended to app/controllers/shared/api.php):

    Http::shutdown()
        ->groups(['api'])
        ->action(function () {
            \gc_collect_cycles();
        });

    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.

  5. removed
    product / functions
    product / vcs
    product / domains
    product / sites
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    product / storage

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions