I'm testing the REQ->REP pattern with multiple reply workers to test concurrent behavior.
Have 3 applications, 2 clients and 1 server, running on same node. Each, which is essentially the client from the zmq guide, has a REQ socket that connects to the server (tcp://127.0.0.1:nnnn). They simply loop sending messages and waiting for the reply and timing how long it takes to get the reply. The server, which is essentially the mtserver from the zmq guide, has an external ROUTER that binds to (tcp://127.0.0.1:*). Internally it has a DEALER with n workers, where each worker is on its own thread and has a REQ socket that connects locally to DEALER. The ROUTER and DEALER use the zmq_proxy to map external messages to internal messages. Each REP worker receives a message and sleeps for some number of seconds to simulate work time and then sends a reply. In my test I have two REP workers configured on the server. I figured one for each client to get concurrent behavior. Worker1 sleeps for 1 sec and Worker2 sleeps for 2 seconds. Based on this I would expect concurrent behavior and the clients to show that messages take either 1 or 2 seconds to complete. When I start the first client I see messages take either 1 or 2 seconds based on which worker processed the message, which I expect. Then when I start the 2nd client I see, on both clients, that some messages take 3 seconds to complete. Looking further, all of the messages that take 3 sec to complete come from Worker2. Looks like only the first message processed by Worker2 after the second client starts completes in 2 seconds. My logs show that when Worker2 takes 3 seconds to complete it's receiving the client's message 1 sec after the client sent it. This accounts for the additional time but I'm not understand why this is happening. Is this the correct behavior? I also re-ran the test where each Worker sleeps for 2 secs. In this case the clients showed that all work, from each Worker, completed in 2 secs which I expected.
_______________________________________________ zeromq-dev mailing list zeromq-dev@lists.zeromq.org https://lists.zeromq.org/mailman/listinfo/zeromq-dev