I imagine this is something that has been asked before, and answered, but I have no idea what to search to find it. This occurs to me as something that you would learn as part of a college course on computer networking - something I never took. If someone can point me towards the answer, that would be great.
So, the question is:
In many languages, like Go and JavaScript, it is relatively simple to make a "GET" request to an API over http/https. But what is happening under the surface, in a relatively high-level description?
I ask because I need a better understanding to grasp how to handle various errors that I receive when things don't behave as they should.
For an idea of the kind of answer I'm going for, I'll refer to the Golang method of making http calls. In Golang, you can import the net/http
package and make the call as such http.Get("http://www.example.com")
. But you can also specify a "client" which you can configure to have things like specific customized headers, etc. You can specify some more complex things inside the client like the transport used, and more, stuff that I'm not really interested in unless it solves my problem.
Basically, it comes down to this: Go is completely concurrent, and in my case parallel. I'm making around 300 requests every second to one API. The suggestion from the golang docs is that clients are safe for concurrent use, so should only instantiated once - essentially, I have one global client through which flows every request.
If I get an error saying that a connection has been killed, does that affect one request, many requests, do I have to do anything to the client to get another connection?
Also, is it one request per connection at a time, or is there a new connection made for every request? Are connections persistent between requests, what determines when they die?
This question is probably pretty rambling, and may not make sense. If anyone can answer any section of it, that would greatly be appreciated.