[go-nuts] Re: Performance hit when using goroutine

2018-05-22 Thread Hawari Rahman
Hi Dave, Yeah, I guess that's the way I'm going to go now. By the way, about the usage of the channels in my snippet, is there any catch from that? On Tuesday, May 22, 2018 at 3:46:13 PM UTC+7, Dave Cheney wrote: > > The best tool to investigate this problem is the execution tracer. It will > s

Re: [go-nuts] Performance hit when using goroutine

2018-05-22 Thread Hawari Rahman
Hi Justin, Yes, it is using index scan, which makes me even more puzzled. On Tuesday, May 22, 2018 at 3:45:29 PM UTC+7, Justin Israel wrote: > > > > On Tue, May 22, 2018, 6:35 PM Hawari Rahman > wrote: > >> After some more detailed investigation, it seems the most time

Re: [go-nuts] Performance hit when using goroutine

2018-05-21 Thread Hawari Rahman
After some more detailed investigation, it seems the most time consuming process is a "Select by IDs" query. So to hydrate a Collection object, I need to retrieve another objects through a SELECT WHERE id = ANY(?)" query in postgres. I'm curious on how the performance can differs greatly when c

Re: [go-nuts] Performance hit when using goroutine

2018-05-21 Thread Hawari Rahman
urrent requests? > In that case, what should I look out for? I've always assumed that using a global *sql.DB will always suffice. On Tuesday, May 22, 2018 at 12:36:25 PM UTC+7, Burak Serdar wrote: > > On Mon, May 21, 2018 at 11:12 PM, Hawari Rahman > > wrote: > > Hi Everyone,

[go-nuts] Performance hit when using goroutine

2018-05-21 Thread Hawari Rahman
Hi Everyone, So for the background, I have an API for retrieving data from a database. For an endpoint there exists two function calls: - SelectCollections - for retrieving the collection records - HydrateCollection - for hydrating each collections (the second function is called on each results

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

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

2017-09-06 Thread Hawari Rahman
Hi Jakub, Yes, that's what we're finally doing now, we're using separate http.Client for each microservice. And I can say that the performance improvement is quite significant. Based on your comment, can you maybe give me an insight on the relationship between http.Client and http.Transport? Ca

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

[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