Repository navigation
Stream large S3 downloads while preserving overwrite consistency - #14605
Conversation
|
Review complete. 🟡 3 medium 💬 Inline comments (3)
This PR extends
Reviewed commit: d806169 |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
There was a problem hiding this comment.
Adds chunked streaming support to the Utopia HTTP response and a lock-guarded S3 GET object endpoint that streams downloads with per-chunk size accounting.
Key findings
- 🟡 Streaming download holds object lock for full duration — Get.php:126
- 🟡 Terminal
end()fired afterclose()in stream abort — Get.php:292 - 🟡 Lock contention surfaces as generic 500, not SlowDown — Get.php:298
🟢 Tier S · Ready to mergeS3 GET and range responses capture the object stream and metadata while holding the object lock, then forward bounded chunks after releasing it. The HTTP response layer accounts for streamed bytes and handles rejected writes and aborted Swoole streams, with regression coverage for streaming and completion behavior. Latest changes: The latest commit adds an explicit assertion that the empty-final-chunk E2E response includes parsed headers before its status is checked.
📂 Walkthrough · 7
Reviewed the commits since |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Large S3 GETs currently cast the storage stream to a PHP string and split the complete body again before sending it. A 100 MiB GET exhausts a 192 MiB PHP process.
Capture the storage stream with its metadata under the existing object lock, then release the lock before forwarding bounded chunks. Local storage returns an open file handle; the S3 adapter returns a private temporary-file snapshot that consumes disk proportional to the object/range until delivery finishes. S3 overwrite uses a fresh version path, so unlinking the previous path cannot change the captured stream. Slow downloads no longer hold the object lock or its Redis connection during client delivery.
This removes whole-object PHP string buffering. The S3 adapter still fetches the object into its private temporary file before returning; this change does not provide end-to-end backend streaming or promise a lower backend first-byte time. The NYC benchmark will measure the effect after deployment.
Small downloads and HEAD keep their existing framing. S3 object GETs consistently return the stored representation regardless of Accept-Encoding, while preserving stored Content-Encoding metadata; both full and range responses are covered through raw, non-decoded clients. This intentionally removes automatic HTTP compression of small S3 object responses too.
Also count streamed HTTP bytes for usage, abort incomplete streams without a terminal chunk, stop when a transport write is rejected (with a red/green regression), and map distributed lock contention to S3 SlowDown/503 centrally.
Validation:
Tracking: https://github.com/appwrite-labs/cloud/issues/6599. The reviewed candidate is deployed in NYC via application-configuration#623. Production HEAD, multipart, large range and 100 MiB concurrent-overwrite probes pass; the full benchmark is running.