FAQ
I'm working on an application that is a web server. Almost all the handlers
work by making an http request to an api, parsing the response, and
delivering a response to the client.

I'm using net/http for the server, which as I understand it already creates
a goroutine for each request. With that in mind, is there any reason I
should also make the request to the api provider a goroutine and use
channels to retrieve a response to parse?

Most of my experience with concurrent type programming is using python
tornado which is an event loop, so in that environment you explicitly make
remote http requests labeled as asynchronous so they don't block. I believe
with go, the fact that net/http has already created a goroutine for the
request I have no need to try and make the api requests goroutines unless I
want to do multiple api requests in the same response handler.

Am I understanding things right?

--
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 golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Kamil Kisiel at Apr 10, 2013 at 10:31 pm

    On Wednesday, April 10, 2013 3:22:07 PM UTC-7, bowman...@gmail.com wrote:

    I'm working on an application that is a web server. Almost all the
    handlers work by making an http request to an api, parsing the response,
    and delivering a response to the client.

    I'm using net/http for the server, which as I understand it already
    creates a goroutine for each request. With that in mind, is there any
    reason I should also make the request to the api provider a goroutine and
    use channels to retrieve a response to parse?

    Most of my experience with concurrent type programming is using python
    tornado which is an event loop, so in that environment you explicitly make
    remote http requests labeled as asynchronous so they don't block. I believe
    with go, the fact that net/http has already created a goroutine for the
    request I have no need to try and make the api requests goroutines unless I
    want to do multiple api requests in the same response handler.

    Am I understanding things right?
    I think you have the right idea.

    --
    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 golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 10, '13 at 10:22p
activeApr 10, '13 at 10:31p
posts2
users2
websitegolang.org

2 users in discussion

Kamil Kisiel: 1 post Bowman Joseph: 1 post

People

Translate

site design / logo © 2021 Grokbase