/await-flow-control

demo goroutines blocking in golang.org/x/net/http2/trasport.go awaitFlowControl

Primary LanguageGo

goroutines blocking in golang.org/x/net/http2/trasport.go awaitFlowControl

If an http2 server is created and does not read the contents of a request body, under load it causes many goroutines to block in awaitFlowControl.

Run the demo server:

go run server.go -cert cert.pem -key key.pem

Run the demo client:

go run client.go -cert cert.pem -key key.pem

The client program will send an additional 2000 requests for each line read from stdin.

Visit http://localhost:6060/debug/pprof/goroutine?debug=1 in your browser. There should be some number of goroutines with a stack trace similar to:

406 @ 0x30f23 0x30fe4 0x41381 0x1dfbfb 0x1797e7 0x178fed 0x180597 0x60421
# 0x41381   sync.runtime_Syncsemacquire+0x201       /usr/local/Cellar/go/1.6/libexec/src/runtime/sema.go:241
# 0x1dfbfb  sync.(*Cond).Wait+0x9b            /usr/local/Cellar/go/1.6/libexec/src/sync/cond.go:63
# 0x1797e7  golang.org/x/net/http2.(*clientStream).awaitFlowControl+0x227 /Users/adamduke/go/src/golang.org/x/net/http2/transport.go:905
# 0x178fed  golang.org/x/net/http2.(*clientStream).writeRequestBody+0x25d /Users/adamduke/go/src/golang.org/x/net/http2/transport.go:820
# 0x180597  golang.org/x/net/http2.(*ClientConn).RoundTrip.func1+0x87 /Users/adamduke/go/src/golang.org/x/net/http2/transport.go:675

Run the server and read the request bodies:

go run server.go -cert cert.pem -key key.pem -read-body

Run the demo client:

go run client.go -cert cert.pem -key key.pem

Visit http://localhost:6060/debug/pprof/goroutine?debug=1 in your browser. There should no goroutines blocking in awaitFlowControl.