I'm seeing "
http2: no cached connection was available" failures from http.Client when I start many (~hundreds) requests at once. (This issue was also posted to golang-nuts@ in April, with no response)
I may not understand correctly, but I thought this kind of usage was fine with HTTP 1.1 and net/http, because the spec mandates a max number of outgoing connections to any given host, so http.Client throttles open connections and effectively queues requests past that. The http2 package seems not to do the same. That might be correct according to the spec (I don't know), but makes using http.Client weird -- I need to rate limit its usage if the server is HTTP 2, but it does rate limiting for me if the server is HTTP 1.1.
Is my understanding correct? Is this a bug? Is the expectation that my app should be rate limiting, regardless of server version?
$ GODEBUG=http2client=0 go run /tmp/foo.go
$ GODEBUG=http2client=0 go run /tmp/foo.go
$ GODEBUG=http2client=0 go run /tmp/foo.go
$ GODEBUG=http2client=0 go run /tmp/foo.go
$ GODEBUG=http2client=0 go run /tmp/foo.go
$ GODEBUG=http2client=1 go run /tmp/foo.go
...
$ GODEBUG=http2client=1 go run /tmp/foo.go
$ GODEBUG=http2client=1 go run /tmp/foo.go
$ GODEBUG=http2client=1 go run /tmp/foo.go
...
$ GODEBUG=http2client=1 go run /tmp/foo.go
...