Skip to content

[Enhancement][gRPC] Bound aggregated streaming responses and define downstream flow control #7928

Closed

Description

@cloudbase-ai

Is there an existing issue for this?

  • 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

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 concerns sending client/bidi requests. This issue concerns result retention and the HTTP response contract; WebSocket forwarding is outside its scope.

Activity

  1. self-assigned this
    on Oct 21, 2026
  2. dmsolr commented on Oct 21, 2026

    @dmsolr
    Member

    Taking this. Will submit a PR shortly: add configurable aggregate result-count and payload-byte budgets to the gRPC plugin (opt-in, default unlimited for backward compatibility). On budget exhaustion the underlying RPC is cancelled, retained results are released and a documented error is returned instead of a success-shaped partial aggregate.

  3. added a commit that references this issue on Oct 23, 2026
    fe411d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions