I'm using ZeroMQ 3.2.3 and CZmq 1.4.1. I gave the "Hello world" sample a try. That sample (https://github.com/imatix/zguide/tree/master/examples/C), when using 10 concurrent clients, allows me to exchange at most 12500 messages per second on a Intel i7 (8 GB RAM, total 8 cores) on the localhost (Ubuntu 13.04).
I read ZeroMQ could handle much more. Am I doing something wrong, or missing something ?
Here is the sample code :
// Hello World server
#include <zmq.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
int main (void)
{
// Socket to talk to clients
void *context = zmq_ctx_new ();
void *responder = zmq_socket (context, ZMQ_REP);
int rc = zmq_bind (responder, "tcp://*:5555");
assert (rc == 0);
while (1) {
char buffer [10];
zmq_recv (responder, buffer, 10, 0);
//printf ("Received Hello\n");
zmq_send (responder, "World", 5, 0);
//usleep (1); // Do some 'work'
}
return 0;
}
// Hello World client
#include <zmq.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
int main (void)
{
printf ("Connecting to hello world server...\n");
void *context = zmq_ctx_new ();
void *requester = zmq_socket (context, ZMQ_REQ);
zmq_connect (requester, "tcp://localhost:5555");
int request_nbr;
for (request_nbr = 0; request_nbr != 100000; request_nbr++) {
char buffer [10];
// printf ("Sending Hello %d...\n", request_nbr);
zmq_send (requester, "Hello", 5, 0);
zmq_recv (requester, buffer, 10, 0);
// printf ("Received World %d\n", request_nbr);
}
zmq_close (requester);
zmq_ctx_destroy (context);
return 0;
}
Thank you !