Skip to content

gRPC streaming responses smaller than 4KB are buffered indefinitely #3188

@tanzeeb

Description

@tanzeeb

In what area(s)?

/area networking

What version of Knative?

HEAD

Expected Behavior

Streaming gRPC responses should be returned immediately.

Actual Behavior

Streaming gRPC responses are held until a 4KB buffer is filled.

Steps to Reproduce the Problem

Reported by @fbiville:

@ericbottard and I worked together to investigate the response buffering issue.
As suggested by @dprotaso last Friday, we tried again to deploy our https://github.com/fbiville/hello-grpc Go server in the following setups:

  1. plain Kubernetes (no Istio, no Knative)
  2. plain Kubernetes + Istio (no Knative)
  3. Knative + @tanzeeb's PR knative/serving#2539

You can check the commit history of this project to follow what we exactly did (https://github.com/fbiville/streaming-loudly).

The buffering issue occurred only in situation 3.

After digging in Knative/serving codebase, we found that the queue-proxy transport uses buffered IO and the writer holds a buffer of 4K.

The code paths are approximately like:
cmd/queue/main h2cproxy httputil.ReverseProxy -> ReverseProxy#ServeHTTP transport.RoundTrip -> http2.transport#RoundTrip GetClientConn -> newClientConn -> buf.NewWriter with the default size

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions