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:
- plain Kubernetes (no Istio, no Knative)
- plain Kubernetes + Istio (no Knative)
- 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
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: