Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asynchronous tasks. Which architecture? (Or pattern in zeroMQ)

I want one application on a Linux(Server) host to communicate with applications on Win7(Client) in a VM. Lib of choice is ZeroMQ. But how do I manage asynchronous tasks?

Let me give an example: The application in the VM generates tasks in arbitrary intervals and sends them to the Linux box. This will process them but needs some time to answer. In this time the socket in REQ/REP pattern is blocked and incoming tasks from the WinApp can not be forwarded to the LinuxApp. How should I solve this? How is this generally solved, even without 0MQ. Do I have to make both to servers and clients and establish two connections?

Requirements:

  • A client is a unique task generator.
  • Server creates a workerthread for each connecting client.
  • Server establishes a unique connection between client an workerthread.(Some tunnle)
  • -> (REQ/REQ between each client-workerthread pair over one socket)
  • Server must forward incoming tasks instantly.
  • Server must be able to handle multiple clients (and therefore connections to WTs).

Hence its not possible to achieve the REQ/REP/REQ/REP/... sequence.

like image 834
ManuelSchneid3r Avatar asked Jun 13 '26 07:06

ManuelSchneid3r


2 Answers

Have a look at the several patterns described in the ZMQ Guide and see if one of them fits better than simple REQ/REP.

In general your server on the linux box seems to need implementation of ROUTER/DEALER pattern that will forward incoming tasks to a set of workers.

ZMQ has it's own topology compared to traditional socket based client/server solutions. Other solutions might be to implement a socket based server that uses a thread pool to forward the incoming tasks.

UPDATE: Since you've been precising on your requirements I think the majordomo pattern might be a good and reliable starting point for your purposes. There might be better fitting patterns as @gvd mentions in his comments.

like image 95
πάντα ῥεῖ Avatar answered Jun 14 '26 21:06

πάντα ῥεῖ


As DevNoob says, the asynchronous client server pattern sounds like the one you need.

"LRU" means least-recently used, but I've removed that term from the latest text of the Guide, and am using "load-balancing" instead. Since the goal is to load-balance across a set of workers...

like image 31
Pieter Hintjens Avatar answered Jun 14 '26 20:06

Pieter Hintjens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!