Re: [go-nuts] Multiple HTTP Clients best practice

2017-09-06 Thread Hawari Rahman
Hi Shawn, Based on what we've experienced after using separate http.Client per microservices (see my previous reply), my best guess that it was because of connection reuse. Since we now have each connection pool dedicated to single host only, it helps performance quite significantly. Thank you

Re: [go-nuts] Multiple HTTP Clients best practice

2017-09-06 Thread Shawn Milochik
Very good question. I don't know, and obviously it would be preferable to understand what's really going on. From a distance the best I can do is guess. If you did try it with multiple clients and it fixes the problem then that should point you in the right direction. If not, try Go's profiler, di

Re: [go-nuts] Multiple HTTP Clients best practice

2017-09-06 Thread Hawari Rahman
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 , it states that an http.Client is concurrent safe and should be reused instead

Re: [go-nuts] Multiple HTTP Clients best practice

2017-09-06 Thread Shawn Milochik
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, what

[go-nuts] Multiple HTTP Clients best practice

2017-09-06 Thread Hawari Rahman
Hello everyone, We're building an API Gateway in our company. Basically what this gateway does is that it processes request from external clients and when doing so, it communicates with our microservices. Some request can have as much as 5 microservices to communicate with in order to be proces