Version
main
Describe the bug.
While looking through crates/bmc-proxy/src/bmc_proxy.rs, I noticed the proxy fully buffers the upstream BMC response before returning anything to the downstream client.
The request path has an explicit 8 MiB cap via MAX_BODY_SIZE, but the response path does:
upstream_response.bytes().await
- then
Body::from(body)
So a large Redfish response gets fully materialized in memory before the client sees the first byte. On the BMC proxy hot path that can cause avoidable memory spikes under concurrency, and it also adds latency because the response is not streamed through as it arrives.
I would expect the proxy to stream the upstream response body back to the client, or otherwise enforce an explicit response-size limit if full buffering is required for some reason.
Minimum reproducible example
- Send a proxied request through
carbide-bmc-proxy to a BMC endpoint that returns a large payload.
- Observe that the proxy waits to read the full upstream body before it starts sending the downstream response body.
- Under concurrent large responses, memory usage scales with the number and size of in-flight upstream responses.
Relevant log output
No specific runtime log here. This came from reading the current main branch implementation.
Other/Misc.
A few details that made this stand out:
- the request side is capped, but the response side is not
- this behavior appears to date back to the initial authenticated BMC proxy implementation (
9001ac23)
- later BMC proxy changes kept the same buffering model, so this looks like an implementation gap rather than a recent regression
Happy to send a follow-up PR to switch this path to streaming if that direction makes sense.
Version
main
Describe the bug.
While looking through
crates/bmc-proxy/src/bmc_proxy.rs, I noticed the proxy fully buffers the upstream BMC response before returning anything to the downstream client.The request path has an explicit 8 MiB cap via
MAX_BODY_SIZE, but the response path does:upstream_response.bytes().awaitBody::from(body)So a large Redfish response gets fully materialized in memory before the client sees the first byte. On the BMC proxy hot path that can cause avoidable memory spikes under concurrency, and it also adds latency because the response is not streamed through as it arrives.
I would expect the proxy to stream the upstream response body back to the client, or otherwise enforce an explicit response-size limit if full buffering is required for some reason.
Minimum reproducible example
carbide-bmc-proxyto a BMC endpoint that returns a large payload.Relevant log output
No specific runtime log here. This came from reading the current
mainbranch implementation.Other/Misc.
A few details that made this stand out:
9001ac23)Happy to send a follow-up PR to switch this path to streaming if that direction makes sense.