NGINXEnvoy Proxy

Unbounded upload size exhausts memory in Starlette applications

warning
Resource ContentionUpdated Mar 25, 2026
How to detect:

Starlette/FastAPI has no built-in global limit on request body size. Large file uploads or streaming requests can exhaust server memory if the entire body is read into memory, leading to OOM kills or severe performance degradation under load.

Recommended action:

Enforce body size limits at the reverse proxy layer (Nginx client_max_body_size, Envoy per_connection_buffer_limit_bytes). For file uploads, use StreamingResponse and process data in chunks rather than loading entire files into memory. Consider implementing custom middleware to reject oversized requests early.