Skip to content

HTTP proxying of unchunked responses buffers entire response to memory #18546

Description

@mbaynton

Problem Statement

Describe the problem for which you are creating this issue.

When the http proxies in rstudio-server receive a response that is not using chunked transfer-encoding, the entire response is buffered to memory before being forwarded. This has at least two clear downsides, inefficient use of/unbounded use of memory, and high time to first byte (at least, of the response body) from the client's perspective.

Proposed Behaviour

Describe the proposed behaviour which would solve the problem above.

All proxied responses are forwarded in a manner that avoids full response buffering and begins forwarding response data while the upstream response is still in progress.

ℹ️ The initial implementation will not cover the session proxy, only the localhost proxy.

QA Notes

Once you have opened a PR, add additional information for QA on how to validate the change, paying special attention to the level of risk, adjacent areas that could be affected by the change, and any important contextual information not present in the original description.

Existing regression / e2e testing should be sufficient to verify core functionality is not disrupted. To verify the new behavior functions correctly, it is necessary to generate a large unchunked http response from a process running on localhost. One way to do this is to run this shiny app from inside RStudio. You can verify accuracy of the downloaded data via sha comparison, and can verify rss of rsession does not spike to greater than the download after transferring a large file.

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions