gideonaire
gideonaire

Reputation: 3

Can disque handle RPC?

I have implemented a RPC which is disqueue-node on npm. My concern is that I have achieved this using 3 tcp connections for request, response and replyQueue. In the reason that get jobs waits until it gets jobs then hangs up the rest of the commands. Do you think it can be achieved using 1 tcp connection?

Upvotes: 0

Views: 165

Answers (1)

antirez
antirez

Reputation: 18514

If you want to use both GETJOB and ADDJOB in the context of the same connection, you may want to use either short timeouts or the NOHANG option of GETJOB in order to avoid blocking if there are no messages to be fetched, and retry from time to time.

Note that TCP connections when idle are mostly for free, so I would not fight too much with that if you don't have a connections scalability problem yet. Moreover given the distributed nature of Disque you can distribute connections to multiple nodes in the future very easily, if you'll ever need that.

Btw in the case you have a pretty trivial RCP protocol: request, response, there should be no problem in blocking, like in:

    ADDJOB ... your RCP request
    reply = GETJOB ...

You still need a reasonable GETJOB timeout in order to inform the caller that the re was a problem receiving the reply in time. And maybe it is worth to return the original job ID to the caller, so that it can decide to wait more for the reply (in case the RCP is non cheap to retry or alike).

Upvotes: 0

Related Questions