top | item 21568264

(no title)

jjbiotech | 6 years ago

Doesn't the native net/http server spin up a goroutine for every request?

Edit: See line 2927 at https://golang.org/src/net/http/server.go

discuss

order

gnoack|6 years ago

The net/http library is the caller in this case, so that would be consistent with the rule that callers should start goroutines.

Request handlers are a bit of a special case too, in that they are a framework for dispatching tasks to be worked on; what is main() for a command line program is the request handler for a webserver. It seems fair that there is some concurrency coordination happening at the top level.

asdfasgasdgasdg|6 years ago

Yeah, but it doesn't spin up a thousand for every request. And it doesn't require you to start them. It starts them under the covers as part of the API.

jjbiotech|6 years ago

Right. So:

* Don't require users of your API to start [additional] goroutines to use your API correctly.