On 5/14/2013 5:59 PM, dlin wrote:
> There are C1,C2,... Cn TCP Clients. I have a CommServer and a JobServer
> program. All of them are on separated machines.
> CommServer receives request from C1,C2,...Cn and mark a sequence number on
> the request, then transfer to JobServer.
> JobServer process the request and send the result back to CommServer, then
> CommServer send back to C1,C2,...Cn.
In Go, you may be better off having a goroutine for each
JobServer. Each goroutine gets work units from a queue channel,
makes the request of its JobServer, and waits for the reply.
When a reply comes, it's sent back to whereever it's supposed to
go.
If the reply doesn't come or times out, indicating trouble
at a JobServer, you can send the work unit back to the
queue channel, so another JobServer will do it.
Then that goroutine can report trouble, test the job server
to see if it's up, but not request another work unit until
its job server recovers. It's important to get the
machine failure handling right, or the whole system will
lock up whenever any server fails.
Go's RPC package provides the necessary primitives.
Or you can run a web server on the JobServer machines and
do all this with REST requests.
John Nagle