I have a RESTful API in Golang that my Angular website calls.
Does the Go http module by default handle requests in sequence or concurrently?
Also, if my HandlerFunc in Go calls a python script, would concurrent calls to this HandlerFunc spawn multiple python processes, or would they be blocked till one is complete?
HTTP is a synchronous protocol: the client issues a request and waits for a response. If you are using non-blocking (aka async) IO, the current thread of the client does not really have to wait, but can do other things (see above).
Go's built-in net/http package is convenient, solid and performant, making it easy to write production-grade web servers. To be performant, net/http automatically employs concurrency; while this is great for high loads, it can also lead to some gotchas.
Async/Await is a language feature that provides a simpler interface to asynchronous programming. Golang is a concurrent programming language with powerful features like Goroutines and Channels.
The answer is: Async doesn't change the HTTP protocol. The HTTP protocol is centered around a request and a matching response. That's it. There's no progress reporting, or multiple responses per request, or anything like that.
Yes, by default all http requests can be executed concurrently.
If you are executing a python script, then indeed a separate process will be spawned and they will execute concurrently.
Please note that this carries the potential risk of spawning too many processes and running out of resources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With