Search code examples
gogoroutine

Goroutines on Individual servers


I am working on an application in Go in which I am using goroutines. Each of which connects to third party servers and collects data which is then processed and used in application.

Just as an example :

for _, apiInfo := range apiInfoList {
    go external1.GetResponse(searchReq)
    go external2.GetResponse(searchReq)
    go external3.GetResponse(searchReq)
}

Now these goroutines are running on single server.

Is it possible to run goroutines on individual servers. ? In my case can I run it on three different servers?


Solution

  • A goroutine (it's a single word) by its very definition is a light-weight thread of execution inside a single process managed by an operating system's kernel.

    Hence the question as stated has no sense: if you want a task to be carried out by a separate process you do not need a goroutine — you need a separate process (no matter whether it is to be run on the same machine or not).

    To exchange data between separate processes, you need to use some form of IPC.