Hi Shawn, That's a nice suggestion, but one question comes to mind though: I'm curious on where our previous implementation failed at. From what I learned at golang website <https://golang.org/src/net/http/client.go>, it states that an http.Client is concurrent safe and should be reused instead of created at will. So when should we consider using multiple http.Clients instead of one? Is it based on the load solely?
On Thursday, September 7, 2017 at 1:42:31 AM UTC+7, Shawn Milochik wrote: > > One possibility I saw in a talk on YouTube a couple of years ago (sorry, > couldn't find the link). > > 1. Have a buffered channel of clients. > 2. Try to grab a client from the channel for each request, using a > time.Timer to time out after a reasonable amount of time (one second, 100 > ms, whatever) > 3. If it times out, create a new client and use it. > 4. Regardless of whether you re-used or created the client, put it > into the channel when you're done with it (use a Timer again and just drop > it if it times out). > > You end up re-using a fixed-size set of clients. You're not using one, and > you're not using one per request. Somewhere in between. > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
