On Fri, May 4, 2018 at 5:20 AM, Ankit Gupta <[email protected]> wrote:
>
> I recently wrote a reverse proxy in Go -
> https://github.com/gptankit/serviceq which does load balancing and queues
> failed requests (to dipatch later).
> When I compared perf with nginx, I noticed 15-20 ms higher response times.
> So, I timed each function, and got to know that the code spends most time in
> 3 places -
>
> Read from tcp conn
> Save in a buffer
> Write to tcp conn
>
> 'Save' is necessary addition as I need to re-run the requests. For 'Read'
> and 'Write', I use bufio -
>
> Read:
>         reader := bufio.NewReader(*httpConn.tcpConn)
>         req, err := http.ReadRequest(reader)
>
> Write:
>         writer := bufio.NewWriter(*httpConn.tcpConn)
>
> Why does Go impose me to read from bufio.Reader and not directly from
> io.Reader? I understand the implication for bigger data but for few bytes,
> managing a buffer seems like an overhead.

I'm sorry, I don't understand the question.  Go does not in general
require you to use a bufio.Reader.  Where is that requirement coming
from?


> I am using Go 1.6.

That is pretty old now.

Ian

-- 
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.

Reply via email to