cloudbase-ai opened a new issue, #7928:
URL: https://github.com/apache/shenyu/issues/7928

   ### Is there an existing issue for this?
   
   - [x] I searched open/closed issues and PRs for gRPC streaming memory, 
buffering, backpressure and flow control; I did not find an equivalent report.
   
   ### Current Behavior
   
   The gRPC plugin exposes an aggregated HTTP/JSON result, including for 
SERVER_STREAMING and BIDI_STREAMING calls:
   
   1. `MessageWriter.onNext()` appends accepted response items (JSON-object 
payloads, or blank payloads) to `ShenyuGrpcResponse.results`.
   2. `results` is an `ArrayList` with no aggregate item-count or byte budget.
   3. `ShenyuGrpcClient.call()` completes its result future only when the RPC 
finishes.
   4. `GrpcPlugin` waits for that future before publishing the aggregated 
result to the subsequent HTTP response path.
   
   Consequently, the HTTP client's consumption rate cannot regulate receipt of 
upstream messages while this aggregation is in progress. Retained results can 
grow until RPC completion or failure/deadline. grpc-java's HTTP/2 flow control 
still exists, but its default inbound delivery proceeds as `onNext` returns; 
appending to a list does not reflect HTTP-client demand.
   
   `maxInboundMessageSize(100 MB)` limits an individual gRPC message, not the 
total accumulated stream. A deadline limits duration, not total retained bytes 
at an arbitrary message rate. No production OOM or heap threshold is claimed 
here.
   
   ### Expected Behavior
   
   Define a bounded response policy for the existing aggregation contract. If a 
demand-aware HTTP streaming mode is added, define its wire/error contract 
explicitly rather than silently changing the existing JSON response shape.
   
   ### Evidence
   
   - [Response 
accumulation](https://github.com/apache/shenyu/blob/87c22dde7be14c1c3755440a4d8b082a86d10a87/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-grpc/src/main/java/org/apache/shenyu/plugin/grpc/proto/MessageWriter.java#L60-L73).
   - [ArrayList-backed 
results](https://github.com/apache/shenyu/blob/87c22dde7be14c1c3755440a4d8b082a86d10a87/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-grpc/src/main/java/org/apache/shenyu/plugin/grpc/proto/ShenyuGrpcResponse.java#L32-L47).
   - [Future completed after RPC 
termination](https://github.com/apache/shenyu/blob/87c22dde7be14c1c3755440a4d8b082a86d10a87/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-grpc/src/main/java/org/apache/shenyu/plugin/grpc/client/ShenyuGrpcClient.java#L104-L123)
 and [HTTP result 
handoff](https://github.com/apache/shenyu/blob/87c22dde7be14c1c3755440a4d8b082a86d10a87/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-grpc/src/main/java/org/apache/shenyu/plugin/grpc/GrpcPlugin.java#L112-L119).
   - [Per-message size 
limit](https://github.com/apache/shenyu/blob/87c22dde7be14c1c3755440a4d8b082a86d10a87/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-grpc/src/main/java/org/apache/shenyu/plugin/grpc/client/GrpcClientBuilder.java#L65-L73).
   
   ### Suggested Verification and Acceptance
   
   - [ ] Define configurable aggregate result-count and byte budgets, 
defaults/compatibility, and the bytes being measured. Distinguish a 
payload-byte budget from an exact JVM heap bound.
   - [ ] On budget exhaustion, terminate the underlying RPC, release retained 
results and report a documented error; do not return a success-shaped partial 
aggregate.
   - [ ] Add boundary tests below/at/above the budget, multiple individually 
valid messages, completion, errors and concurrent RPC isolation.
   - [ ] Preserve existing aggregated JSON output for calls within the 
configured limits, including unary and finite streaming calls.
   - [ ] Specify the relationship between aggregated output and downstream 
demand. Bounded aggregation may be the first delivery; it should not be 
described as end-to-end streaming backpressure.
   - [ ] If a streaming mode is proposed, define framing, compatibility, 
pre/post-commit errors, manual inbound demand and downstream cancellation 
before implementation; track it separately if needed.
   - [ ] Validate with a backend producing many valid JSON response messages. 
Record retained results/bytes and memory behavior while completion is delayed; 
measure slow-consumer behavior separately for any streaming mode.
   
   ### Environment and Validation Boundary
   
   Reviewed ShenYu `2.7.2-SNAPSHOT`, master 
`87c22dde7be14c1c3755440a4d8b082a86d10a87`, grpc-java `1.65.1`. This is a 
source-inspection finding. No slow-consumer load test or production memory 
failure was reproduced.
   
   The [companion outbound-readiness 
issue](https://github.com/apache/shenyu/issues/7927) concerns sending 
client/bidi requests. This issue concerns result retention and the HTTP 
response contract; WebSocket forwarding is outside its scope.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to